Zipped TensorFlow Sequential Animal Prediction Model
Zipped Folder of Zipped Train and Zipped test Images used in Video
Expanding our convolution network in this multi-class classification guided project with the Sequential model In TensorFlow with Python. Although you can get more complex with the Sequential model, training a model of this complexity takes a long long time, as in 4 hours with a GPU and those unfortunately those aren't free. Without a GPU it took me roughly 2 weeks of almost constant training for this model to be ready.
This project shows how to use two Convolutional layers in TensorFlow's Sequential model. Convolutional layers in our context are of the common architecture of 2 - 2D Convolutional Layers followed by a 2D Max Pooling layer and then the import Dropout Layer to help with regularization and prevent overfitting. The layers come from the keras sub library inside TensorFlow.
Although we use 2 Convolutional Layers with 4 sub-layers here a common pattern is to have 3 or 4 convolutional layers. Often the 4th layer is only made up of one convolutional.
The Series of convolutional layers is usually followed by a Dense layer but in this project, we wanted to test putting a recurrent layer and chose to use the LSTM recurrent layers in TensorFlow. However to do so we but first have the data pass thrount a Reshape layers simply to add the depth dimension or a , 1 as the z dimension.
A special theme of this problem is planning out how to train a model of this complex without a GPU. There are lots of people who don't have access to a GPU to train their neural networks but that shouldn't stop them from practicing and experimenting with more complex models.
If we're training a model for 10's of hours or days our workbook will often time out and we will loose our model in the middle of training. This could be frustrating but a simple solution is that we save our model on every epoch's end. And then when we eventually run into an area, remember this took 2 weeks training on a CPU, I was able to load up the last epoch
Here we will use ModelCheckpoint callback in TensorFlow to save our model at the end of each epoch or only if it evaluates to a higher accuracy or validation accuracy. In our situation of not using a GPU, it's best to save the model at the end of each epoch because although the score might not be higher the model is learning and the worse score is part of the learning process while layers deeper in our network learner and the latter layers need to adapt to this.
Follow Data Science Teacher Brandyn
dataGroups:
Comments