While building the pet classifier in lesson 1 we used transfer learning, specifically resnet34. Now the actual resnet model is trained to predict 1000 classes, so in order to use it for our purpose(37 classes) we could either modify or add certain layer so that the output dimension is 37.
But in the notebook I saw we directly use
models.resnet34 and do not modify it. Hence I decided to check the resnet34 architecture in fastai and indeed it had the output dimension to be 37. I went ahead and checked the architecture for different models like alexnet, densenet, squeezenet etc and all of them had the output dimension to be 37.
Can anyone please help me out with the below questions:
1.) Are the different architectures in models specifically altered for the lesson 1 notebook or does the model figures it out automatically?
2.) If I want to add certain layers at the end, how do I proceed about it?
Thanks in advance
I can help you out with the first question. See, Jeremy mentioned in the first lesson that the way transfer learning works is by adding a few layers at the end of the model and then training those layers first.
So imagine that you have the entire resnet architecture with 1000 output nodes. Now what fastai does is add a few layers after that so that those new layers can use the knowledge from the resnet ach. These new layers are trained on the input data and the output layer now has 37 neurons. So we do not modify the architecture of the resnet itself, we build on top of it.
Hope this helps
Hi Swastik, Thanks for your reply. Yes I understand that we are only training the last few layers. But what I want to understand is when did Jeremy add those extra layers to the architecture. Because as I mentioned earlier all the different architectures in the models module already had few layers added to them to make the output 37 dimensional.