When we train a new model we train it to find some patterns in our images, text, or any data. But this training new model from scratch takes a lot of time and sometimes doesn’t give us the accuracy we want. That’s where we need transfer learning
What is transfer learning?
Transfer learning is using weights of the model which is previously built on a similar kind of problem we are working on. This helps us to increase accuracy over our dataset since it’s already trained on a big dataset for lots of epoch(eg Efficientnet model is trained on Imagenet dataset ). Since this model already figured out how to find out patterns in the images and other data we train our rural network to find the pattern on our dataset (which we are giving on training) it increases the accuracy of the model by a substantial amount.
we are freezing the layers of the model to avoid changing the weights of model which is already trained on and adding some more layers to figure out our model our own training dataset.
In this tutorial, we are gonna work towards how we can create a standard classifier using PyTorch
This model will predict if the given image sample contains bees or ants
Step 1: Importing required libraries.
in this step we are importing required libraries
Step 2: Downloading the dataset
here we are using the dataset which is from the PyTorch dataset
Step 3: Loading dataset using Datasets and Dataloader API
For loading the dataset we are using dataset API and datasets.ImageFolder function this function identifies folders based on the standard structure of
main_dir → class names → Image1, Image2,Image3….
Step 4: Exploring dataset, Visualizing what’s in the dataset
exploring dataset using matplotlib
we will discuss the training model and evaluation in the part 2 link