How to get ResNet features from a pre-trained model?

Hi all,

I tried to load a pre-trained ResNetModel, however I’m getting the following weird exception:

Some weights of the model checkpoint at microsoft/resnet-50 were not used when initializing ResNetModel: [‘classifier.1.bias’, ‘classifier.1.weight’]

  • This IS expected if you are initializing ResNetModel from the checkpoint of a model trained on another task or with another architecture (e.g. initializing a BertForSequenceClassification model from a BertForPreTraining model).
  • This IS NOT expected if you are initializing ResNetModel from the checkpoint of a model that you expect to be exactly identical (initializing a BertForSequenceClassification model from a BertForSequenceClassification model).

My code for loading the model is:
model = ResNetModel.from_pretrained(“microsoft/resnet-50”, force_download=True)

And I wanted to use the following code as some pre-trained features:
model(images)[‘pooler_output’] # images is a tensor of images of the correct shape

Is my code incorrect in some way?
From reading related questions I worry that somehow not all parts of the model were loaded correctly.

Thanks,
Tom