Let’s now build and train the model. As mentioned on the previous page, we will use some ResNet variants in the upcoming sections. Rohit will now walk you through the ‘ResNet builder’ module which is basically a Python module containing all the building blocks of ResNet. We will use this module to import the variants of ResNet (ResNet-18, ResNet-34 etc.).
Note that we are not using the ResNet implementation of Keras since it does not provide the flexibility to choose from these variants. The resnet. py module is taken from here (note that you will almost never write these module, you only need to learn to import and use them). We will still walk through the module to understand the architecture better.
Here is the ResNet script that Rohit has used in this video.
To summarise, the resnet. py module contains all the building blocks of ResNet using which we can build all the variants such as ResNet-18, ResNet-34, ResNet-50 etc. In the next few sections, we will use ResNet-18.
Next, let’s move on to data generators. Please refer to the notebook for comments and explanations of the code.
NOTE:
Data generator supports preprocessing – it normalizes the images (dividing by 255) and crops the center (100 x 100) portion of the image.
There was no specific reason to include 100 as the dimension but it has been chosen so that we can process all the images which are of greater than 100*100 dimension. If any dimension (height or width) of an image is less than 100 pixels, then that image is deleted automatically.
You can change it to 150 or 200 according to your need.
Refer to the section Data Generators in your notebook to answer the following questions.
Coming Up
Before we train the full model, it is common to take a small chunk of the data and check whether your model is working on it. This is called an ablation experiment. We shall cover this in the next page.
Report an error