Pytorch cifar10 images are not normalized
transform = transforms.Compose([
    transforms.ToTensor(),
    transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))])

trainset = torchvision.datasets.CIFAR10(root='./data', train=True,
                                        download=True, transform=transform)
  
trainset.data[0]

I am using the above code and expect that data will be normalized. But it is not, below is the result. I need to access data using the data method to do some more processing. Output is below.
array([[[ 59,  62,  63],
        [ 43,  46,  45],
        [ 50,  48,  43],
        ...,
        [158, 132, 108],
        [152, 125, 102],
        [148, 124, 103]],


The torchvision.transforms.Normalize is merely a shift-scale operator. Given parameters mean (the &quot;shift&quot;) and std (the &quot;scale&quot;), it will map the input to (input - shift) / scale.
Since you are using mean=0.5 and std=0.5 on all three channels, the results with be (input - 0.5) / 0.5 which is only normalizing your data if its statistic is in fact mean=0.5 and std=0.5 which is of course not the case.
With that in mind, what you should be doing is providing the actual dataset's statistics. For CIFAR10, these can be for example found here:
mean = [0.4914, 0.4822, 0.4465]
std = [0.2470, 0.2435, 0.2616]

With those values, you will be able to normalize your data properly to mean=0 and std=1.
I've written a more general, long-form answer here.
