Solved by Mona_Jalal in post #7 
              
              
                image_arr = []

for i in range(len(train_dataset)):
    image_arr.append(to_tensor(train_dataset[i]['image']))
                     
mean = torch.mean(torch.stack(image_arr, dim=0), dim=(0, 2, 3))
std = torch.std(torch.stack(image_arr, dim=0), dim=(0, 2, 3))

print(mean.shape)
print("mean is {} and …