Thanks for the update, it looks like I should follow these posts to calculate stats:

  
    
    
    Computing the mean and std of dataset 
  
  
    Hello. So I am trying to compute the mean and the standard deviation per channel of my train dataset (three-channel images of different shapes). 
For the mean I can do it in two ways, but I get slightly different results. 
import torch
from torchvision import datasets, transforms

dataset = datasets.ImageFolder('train',
                 transform=transforms.ToTensor())

First computation: 
mean = 0.0
for img, _ in dataset:
    #mean += img.sum([1,2])/torch.numel(img[0])
    mean += img.mean([1,2…
  



  
    
    
    Efficient way of calculating mean, std, etc of Subset Dataset 
  
  
    I have a Dataset class that loads two datasets from their respective folders (train and test). 
I would like to create a validation set from the training set. For this I am using the random_split function. 
This results in two Subset-Datasets: train_dataset and valid_dataset. For normalization I would like to calculate the mean and std (or min/max) of the training set, but it is not possible to do a simple call of mean() to the dataset, because it is a Subset. 
What I can do is calculate the mea…