Should compute mean and std for new dataset?

I am working on a cv model. I know that I should normalize the dataset by its mean and std.

The backbone is a pre-trained model (resnet-50), and I saw some code just use std and mean computed from Imagenet, which was used to train the backbone.

But now, I am working on another dataset A, other than Imagenet. Should I change std and mean from Imagenet to A?

sincerely thanks.

It depends a bit on your use case.
E.g. if your new dataset is quite small, but originates from the same domain (“natural” images like in ImageNet), you could still use the ImageNet stats.
However, if your new dataset contains images from another domain, e.g. medical CT scans, I would rather calculate the new statistics, as they might differ a lot.

1 Like

Thanks for your reply, this helps me a lot.!