Here is my third week of Deep Learning with PyTorch: Zero to GANs.
In this blog, we will take a look at What is a neural network, What is CIFAR-10 dataset, How to develop & train a neural network model, etc.
What is a Neural Network?
Neural networks are a set of algorithms. These algorithms interpret the received data into real-world data that are images, sound, text, videos, and series. Neural networks are multi-layer networks of neurons that we use to classify things, make predictions, etc.
What is so special about a neural network?
- It is used to resolve highly complicated problems existed in a real-world scenario.
- Highly complicated algorithms can work more efficiently than a human brain.
- Reduces the chance of risks and mistakes.
- It possesses more versatility than humans.
What is CIFAR-10 Dataset?
The CIFAR-10 dataset is consists of 60,000 (50,000 dataset & 10,000 test dataset) 32×32 pixel color photographs of objects from 10 classes. The class labels and their standard associated integer values are listed below.
Load CIFAR-10 Dataset:
Number of Images belonging to each class:
Here you can see from the 50,000 datasets each class has the same number of images.
Prepare The Training Model:
We’ll use a validation set with 5000 images (10% of the dataset). To ensure we get the same validation set each time, we’ll set PyTorch’s random number generator to a seed value of 43.
Let’s use the
random_split method to create the training & validation sets
We can now create data loaders to load the data in batches.
Traning The Model:
Now, Extend the ImageClassificationBase class to complete the model definition. For class details, you can check here My Notebook.
Now, Check the validation loss & accuracy.
Finally, we can train the model using the fit function to reduce validation loss & improve accuracy. We will train the model in multiple phases, adjusting the no. of epochs & learning rates each time based on the result of the previous training phase.
Check how well our model can perform on this dataset by plotting the losses and the accuracies.
Finally, evaluate the model on the test dataset report its final performance.
We got almost 55% of accuracy! Here our model can classify images with this rate of accuracy.
By changing no. of epochs & learning rates each time based on the result we may get better accuracy.
- For full code check My Notebook
- CIFAR-10 Dataset
- Machine learning website
- Google search
- Use this data visualization cheatsheet for reference: Click Here.
I hope you liked this post. Feel free to share your ideas, thoughts, and suggestions below.
Let’s Connect — My Linkedin