10.11.2016 Views

Learning Data Mining with Python

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Classifying Objects in Images Using Deep <strong>Learning</strong><br />

Next we set the size of the convolution layers. There are no strict rules here, but I<br />

found the following values to be good starting points;<br />

conv1_num_filters=32,<br />

conv1_filter_size=(3, 3),<br />

conv2_num_filters=64,<br />

conv2_filter_size=(2, 2),<br />

conv3_num_filters=128,<br />

conv3_filter_size=(2, 2),<br />

The filter_size parameter dictates the size of the window of the image that the<br />

convolution layer looks at. In addition, we set the size of the pooling layers:<br />

pool1_ds=(2,2),<br />

pool2_ds=(2,2),<br />

pool3_ds=(2,2),<br />

We then set the size of the two hidden dense layers (the third-last and second-last<br />

layers) and also the size of the output layer, which is just the number of classes in<br />

our dataset;<br />

hidden4_num_units=500,<br />

hidden5_num_units=500,<br />

output_num_units=10,<br />

We also set a nonlinearity for the final layer, again using softmax;<br />

output_nonlinearity=softmax,<br />

We also set the learning rate and momentum. As a rule of thumb, as the number of<br />

samples increase, the learning rate should decrease:<br />

update_learning_rate=0.01,<br />

update_momentum=0.9,<br />

We set regression to be True, as we did before, and set the number of training<br />

epochs to be low as this network will take a long time to run. After a successful run,<br />

increasing the number of epochs will result in a much better model, but you may<br />

need to wait for a day or two (or more!) for it to train:<br />

regression=True,<br />

max_epochs=3,<br />

[ 266 ]

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

Saved successfully!

Ooh no, something went wrong!