[Jing] Refining Tensorflow

This past week I retrained the model several times (15+ times) to optimize our neural network and improve the accuracy the inference. I initially hit an accuracy of 65% and tried several things to improve the accuracy.

First, I added another convolution layer, and it improved the accuracy of our model to 75%. However, adding a second convolution layer made our model overfit. In other words, our model hit a 90% training accuracy, but remained at a 75% validation accuracy. Adding a third convolution layer actually lowered the overall accuracy, likely because our data set is not large enough.

Afterwards, I looked into adding regularization functions to improve our validation accuracy. Regularization functions are supposed to improve overfit models by making the model less responsive to noise. These were already built in to the Tensorflow library, so utilizing them was not difficult. I tried three different regularization functions (the sum of absolute values, sum of squared values, and the sum of both), and applied them to various parameters of the neural network – the bias, kernal, and activity variables. After training several times, I discovered that accuracy was significantly worse for some models, and approximately the same for others.

The only other solution I could think of was to enlarge our data set. From what I’ve looked up online, accuracy performance peaks using a data set of 1000-2000 images per class. Our data set currently only has 500 images each for raccoons, squirrels, and the lower body of humans. Over the next week I’ll scrape some images off of Google to enlarge our data set. Enlarging the data set also means that we can increase the number of parameters our neural network can program. This means we can expand our neural network to work with more layers, which may improve the accuracy.

Before I do that next week, I attempted to make even the number of images per class to see if that would change the results. Because I have over 12000 images each of dogs and cats, I removed 11500 of them from each set, so that each class could have 500 images. After training again, I discovered that the results were approximately the same (75% validation accuracy).

Finally, I played around with the batch size of our neural network. The batch size is a parameter which tells the neural network how many images to process at one step. Initially, this value was set to 32, but the smaller I made it, the more accurate our inference was. When I tuned the batch size down to a size of 8, I was able to get a validation accuracy of 78%. This was the best I could get it up to.

Leave a Reply

Your email address will not be published. Required fields are marked *