Each of the image has got 64 * 64 dimension. The image is grayscale, so channel =1,  I converted the images to TensorDataset which gives me back size of ([1,64,64]) and then i pass this to Dataloader which gives me dimension ([1,1,64,64]) Now if i want to find the mean and std() the following code generates error:

mean = 0.
std = 0.
nb_samples = 0.
for data in loader:
    batch_samples = data.size(0)
   data = data.view(batch_samples, data.size(1), -1)
    mean += data.mean(2).sum(0)
     std += data.std(2).sum(0)
    nb_samples += batch_samples

mean /= nb_samples
std /= nb_samples

It gives me the following error :

AttributeError: ‘list’ object has no attribute ‘size’

ref: @ptrblck
Now where should i run the loop ? In Dataloader object or in the image itself?
My second question is after i find the mean and std dev what is the code to apply the transorms operation, since it is grayscale , will the code be like the following :

train_transform = transforms.compose(transforms.Normalize ([mean,mean,mean],[std,std,std]))


or should it be like this, as it is a grayscale dataset.

train_transform = transforms.compose(transforms.Normalize ([mean],[std]))


And my third question is how can i apply this mean and std() to my dataset , since it is a custom dataset i will not be able to follow instruction where the datasets are imported from torchvision.