Calculating pre-convoluted features
When we freeze the convolution layers and the train model, the input to the fully connected layers, or dense layers, (vgg.classifier
) is always the same. To understand better, let's treat the convolution block, in our example the vgg.features
block, as a function that has learned weights and does not change during training. So, calculating the convolution features and storing them will help us to improve the training speed. The time to train the model decreases, as we calculate these features only once instead of calculating for each epoch. Let's visually understand and implement the same:

The first box depicts how training is done in general, which could be slow, as we calculate the convolutional features for every epoch, though the values do not change. In the bottom box, we calculate the convolutional features once and train only the linear layers. To calculate the pre-convoluted features, we will pass all the training data through the convolution blocks...