Mean and std for transfer learning

I want to use resnet pretrained on Imagenet and fine tune the model on my new dataset (consisting of cell images).
So what must be the mean and std in transforms.Normalize(mean, std, ) .
Should it be that of the ImageNet dataset (coz we are using a pretrained model trained on ImageNet)
or we should pass the mean and std of this new dataset?

What I think is after normalization it must have 0 mean and unit var. and if we pass the imagenet mean and std for my dataset it will not have 0 mean and unit variance and hence both this distributions will be different so hence use mean and std of my new dataset. (Please correct me if I am wrong)

Hi @arjun,
I feel theoretically you’re right and this is the right way, but experimenting with this can possibly have different results based on the difference in size of pre-training and current datasets.
Conducting an experiment would be better.

1 Like

I have just 100 images. So what would be the ideal approach? If I am training only the last layer?
On pytorch discuss forum ppl say that use imagenet mean and std when using pretrained models.
(I think the logic behind this is since the weights of initial layers are freezed we are kind of doing inference on our data and hence use imagenet mean and std)

Yes, this can be a case… and Imagenet has a pretty large corpus, and mean, std from Imagenet can be considered as a good approximation to the population parameters.