You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Normalize transform does not normalize tensor per se. Only if the correct mean and standard deviation are passed as arguments will the output be "normalized" as in zero mean and standard deviation of 1.0.
On its own, all the transform does is shift and scale an image using the arguments passed.
Line 289 of code, Normalize(mean=(0.5,0.5,0.5) and std=(0.5,0.5,0.5))
Which shifts values by 0.5 and scale by 1/0.5
Comment bellow states that above Normalize transformation would make mean zero and standard deviation 0.5, which is not quite (on CIFAR10 final mean = -0.053, and std is 0.503).
As initial colors have values between 0.0 and 1.0, after Normalized transform, they would be shifted by 0.5 and scaled by 1/0.5 making the final values fall in the range -1.0 and 1.0.
transform = transforms.Compose(
[transforms.ToTensor(),
transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))])
##########################################################################
# Here, we specify two transformations for our input:
#
# - ``transforms.ToTensor()`` converts images loaded by Pillow into
# PyTorch tensors.
# - ``transforms.Normalize()`` adjusts the values of the tensor so
# that their average is zero and their standard deviation is 0.5. Most
Normalize transform does not normalize tensor per se. Only if the correct mean and standard deviation are passed as arguments will the output be "normalized" as in zero mean and standard deviation of 1.0.
On its own, all the transform does is shift and scale an image using the arguments passed.
Line 289 of code,
Normalize(mean=(0.5,0.5,0.5) and std=(0.5,0.5,0.5))
Which shifts values by 0.5 and scale by 1/0.5
Comment bellow states that above Normalize transformation would make mean zero and standard deviation 0.5, which is not quite (on CIFAR10 final mean = -0.053, and std is 0.503).
As initial colors have values between 0.0 and 1.0, after Normalized transform, they would be shifted by 0.5 and scaled by 1/0.5 making the final values fall in the range -1.0 and 1.0.
cc @suraj813
The text was updated successfully, but these errors were encountered: