Why put mean and std values ourselves?

transform = transforms.Compose([transforms.ToTensor(), 
                                transforms.Normalize((0.5,0.5,0.5)
                                , (0.5,0.5,0.5))])

I have seen people normlize the pictures this way, I know we do it because after using transforms.ToTensor() the return values range from [0,1], my question is why are we defining mean and std values ourselves? Shouldn’t we actually calculate what the mean and std would be in each case?

Hi Ajeel,

This isn’t the optimal way to normalize your input because you will be shifting the data to a distribution that most likely doesn’t represent the data distribution. The correct way to do this is to measure the mean and the std of your training dataset, then utilize that information to normalize your input.