24.07.2016 Views

www.allitebooks.com

Learning%20Data%20Mining%20with%20Python

Learning%20Data%20Mining%20with%20Python

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Classifying Objects in Images Using Deep Learning<br />

GPU optimization<br />

Neural networks can grow quite large in size. This has some implications for<br />

memory use; however, efficient structures such as sparse matrices mean that we<br />

don't generally run into problems fitting a neural network in memory.<br />

The main issue when neural networks grow large is that they take a very long time<br />

to <strong>com</strong>pute. In addition, some datasets and neural networks will need to run many<br />

epochs of training to get a good fit for the dataset. The neural network we will train<br />

in this chapter takes more than 8 minutes per epoch on my reasonably powerful<br />

<strong>com</strong>puter, and we expect to run dozens, potentially hundreds, of epochs. Some<br />

larger networks can take hours to train a single epoch. To get the best performance,<br />

you may be considering thousands of training cycles.<br />

The math obviously doesn't give a nice result here.<br />

One positive is that neural networks are, at their core, full of floating point<br />

operations. There are also a large number of operations that can be performed<br />

in parallel, as neural network training is <strong>com</strong>posed of mainly matrix operations.<br />

These factors mean that <strong>com</strong>puting on GPUs is an attractive option to speed up<br />

this training.<br />

When to use GPUs for <strong>com</strong>putation<br />

GPUs were originally designed to render graphics for display. These graphics<br />

are represented using matrices and mathematical equations on those matrices,<br />

which are then converted into the pixels that we see on our screen. This process<br />

involves lots of <strong>com</strong>putation in parallel. While modern CPUs may have a number<br />

of cores (your <strong>com</strong>puter may have 2, 4, or even 16—or more!), GPUs have<br />

thousands of small cores designed specifically for graphics.<br />

A CPU is therefore better for sequential tasks, as the cores tend to be individually<br />

faster and tasks such as accessing the <strong>com</strong>puter's memory are more efficient. It is<br />

also, honestly, easier to just let the CPU do the heavy lifting. Almost every machine<br />

learning library defaults to using the CPU, and there is extra work involved before<br />

you can use the GPU for <strong>com</strong>puting. The benefits though, can be quite significant.<br />

GPUs are therefore better suited for tasks in which there are lots of small<br />

operations on numbers that can be performed at the same time. Many machine<br />

learning tasks are like this, lending themselves to efficiency improvements through<br />

the use of a GPU.<br />

[ 258 ]

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!