Hello everyone. In this video, we are going to train our model and set up hyper parameters for it. The hyper parameter that you're going to use in this course, we're picked after a testing period that I performed before recording this course. If you're interested in running tests on your own, and finding out if there are more and better suited hyper parameters for our model, by all means, do that. If you find better combinations, please share them with us in the comment sections, so others can improve their pipelines as well. Our first hyper parameter is ebooks, and we set it to 20.
This number of epochs is very good for our use case. It won't produce over fitted model or under fitted model either for batch size I put 128 but you can tweak this parameter, increase it or decrease it depending on your hardware. Specifically read I have 60 User RAM and I could run up to 256. For the learning rate, just set it to 0.01. This parameter is the trickiest one to tweak, and I was playing with it a lot. If you want to play with this parameter, you might need to change ebooks as well.
Dropout rate is 60% or 0.6. This means that each layer which has dropout regularization on it is going to randomly drop 60% of its units. You can play with this too. But be careful if you set it too high, the network won't be able to learn efficiently. On the other hand, it could overfit with a lower dropout like 30 to 40%. For image size, because we are working with Super 10 data set, just set it to 32 by 32.
Now that we have all of our hyper parameters, it is time to get our training. Testing data to get training images and labels type x train y train, and we are going to get them from data set pre processing. The first argument for this function is data set path. If you go to data set folder, you will have two sub folders, one called train, and other called test. These are exactly what we need to provide set the first argument to data sets slash train. Next, we need to provide a path to our labels.
Txt file. As you may remember, this file is a text file called labels in our data set folder, the first argument is image size, which we have already defined in our hyper parameters. The last argument that we will need to set is the name of pickle file that we will save all of our training image paths. So just a name over the file. You can see Whatever you want, I'll go with train images, people and execute the cell. To get testing data, copy the code that we wrote for the train data and paste it in the new cell.
But before we work on it, let's check the shape of the x train tensor to track that type x train dot shape. And you can see that we have 50,000 images, each image is 32 by 32. And in RGB format, go back to the cell where you want to get your testing data, change x train to x test, and do that for targets as well. Change y train to y test in the function arguments for the first argument instead of data set slash train, right data set slash test. And for the last argument, just change the name of your output pickle file. Let's check if your data set has 10,000 images by using ix test dot shape.
And if that's the next step for us is to create a folder where all checkpoints will be saved. Go to the root folder of your project and create a new folder and name it saver. Now that we have almost all of the pre steps done, let's define our model, type model equals image search model. Provide learning rate, image size, and for number of classes, leave it at 10 create variable data, create variable data that will be tupple and will consist of all training a test subset x train, y train, x test and y test. Okay, now we have everything done. Let's call our training function, type train and provide our model as a first argument.
Then our hyper parameters ebooks, drop probabilities batch size. Then we have our data topple, and lastly saver folder. Leave saver Delta as a default and execute the cell. The training process could take up to a few hours, I will train the model on my PC and upload the saver file to get. You can simply download checkpoints from the repository and test the model to perform the inference or you can train it on your own. If you have any questions, comments or concerns, please post them in the comment section.
Otherwise, I'll see you in the next video.