tris_b:

I inserted 255 and 0 for X and X_norm were 1 and 0. Then I solved the two equations and got 0 for mean and 255 for std.


I see what you did. So if you assign mean=0 and std=255, then that means you are just scaling the range of pixel intensities from to be within [0, 1]. That can be simply done by X_norm = X/255.0 as well.
But also note that if you have a PIL image, and then use the function torchvision.transforms.functional.to_tensor(), the result will already be in the range [0, 1]. so in that case, make sure that do not divide by 255.0 again, otherwise, the pixel values will be really small, within range [0, 0.003921].