Using the entire Resnet model instead of cutting the last 2 layers

In order to create a CNN model, one has to use the cnn_learner function. In order to do Transfer Learning using a Resnet model, one may create a Learner as:-

learn = cnn_learner(data, models.resnet50, pretrained = True, metrics = accuracy)

In this case, the last 2 layers are cut from the model and a combination of different layers are added at the end as described in the docs.

I was wondering how can I get a pure Resnet model with all its layers intact (not removing the last 2 layers), since even with cut=None, it defaults to removing the last 2 layers as mentioned in _resnet_meta.

Hi Rajdeep,

You can easily do this by constructing your learner with Learner instead of cnn_learner.

For example:

learn = Learner(data, models.resnet50(pretrained=True), metrics=[accuracy])

This will give you the ResNet50 with an output dimension of the original one, i.e 1000.

Hope that helps !


Oh, I see. Thank you so much; extremely grateful for your help.