Normalization required for pre-trained model (PyTorch)
I am using a pre-trained model from pytorch:
model = models.resnet50(pretrained=True).to(device)
for param in model.parameters():
    param.requires_grad = False
model.fc = Identity()

Should I normalize the data using my data mean and std or use the values used by the model creators?
class customDataset(torch.utils.data.Dataset):
    'Characterizes a dataset for PyTorch'
    def __init__(self, X, y):
        'Initialization'
        self.normalize = transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])
        self.X = X 
        self.y = torch.tensor(y, dtype=torch.float32)
    
    def __len__(self):
        return len(self.X)

    def __getitem__(self, idx):
        X = self.X[idx]
        X = ToTensor()(X).type(torch.float32)[:3,:]
        X = self.normalize(X)
        return X, self.y[idx]


You must use the normalization mean and std that was used during training. Based on the training data normalization, the model was optimized. In order for the model to work as expected the same data distribution has to be used.
If you train a model from scratch, you can use your dataset specific normalization parameters.
