I indexed my list of Tensor as follows :
The Dataloader object has 2 lists. One is the images and another list is the labels. In order to find the mean and standard deviation , i need to go through the batches and have mean and std() for each batch.
Am i indexing it correctly? pls see below. i named it T in the following code. When i print T it gives me back the tensors, But i could not perform T.size on it, it gives me the error,
AttributeError: ‘list’ object has no attribute ‘size’
for data in train_loader:
    T = [data[0]]
print(T)
[tensor([[[[0.3264, 0.1983, 0.2149,  ..., 0.1405, 0.1281, 0.1240],
      [0.2273, 0.2603, 0.2479,  ..., 0.1240, 0.1198, 0.0992],
      [0.2810, 0.2893, 0.2479,  ..., 0.1198, 0.1198, 0.1074],
      ...,
      [0.7975, 0.8182, 0.8058,  ..., 0.2893, 0.1983, 0.0992],
      [0.8058, 0.8347, 0.8017,  ..., 0.3140, 0.2273, 0.1033],
      [0.8223, 0.8430, 0.8099,  ..., 0.3182, 0.2562, 0.1157]]],


    [[[0.4298, 0.4587, 0.5496,  ..., 0.4959, 0.4959, 0.4959],
      [0.4421, 0.4545, 0.5331,  ..., 0.4917, 0.4917, 0.4959],
      [0.4669, 0.4587, 0.5207,  ..., 0.4835, 0.4876, 0.4917],
      ...,
      [0.4421, 0.4339, 0.4380,  ..., 0.3636, 0.3802, 0.3802],
      [0.4421, 0.4339, 0.4380,  ..., 0.3802, 0.3802, 0.3760],
      [0.4421, 0.4380, 0.4339,  ..., 0.3843, 0.3843, 0.3719]]],


    [[[0.1240, 0.0992, 0.1240,  ..., 0.1983, 0.1818, 0.1653],
      [0.1157, 0.1033, 0.1281,  ..., 0.1901, 0.1570, 0.1488],
      [0.1074, 0.1074, 0.1240,  ..., 0.1694, 0.1488, 0.1364],
      ...,
      [0.9008, 0.6901, 0.2810,  ..., 0.5620, 0.6488, 0.4959],
      [0.9132, 0.6983, 0.3099,  ..., 0.5455, 0.6198, 0.5744],
      [0.9091, 0.7562, 0.2851,  ..., 0.4793, 0.6198, 0.6157]]]

What i meant by the third question is that usually when we download dataset from torchvision there is a parameter called transform where we can pass in ‘transformation’ variable which includes the mean and std() values, as a result it goes through the whole dataset and normalizes it. My question is after i calculate mean and std() for my custom dataset how do i apply it in order to normalize my data so that it goes through for all the batches and normalizes it ?
transformation = transforms.Compose([transforms.ToTensor(),
                               transforms.Normalize((0.1307,),(0.3081,))])
train_dataset = torchvision.datasets.MNIST('./data',train=True,transform= transformation, download= True)