densenet.pytorch icon indicating copy to clipboard operation
densenet.pytorch copied to clipboard

A problem when computes cifar10 mean and stdev

Open xuyan1115 opened this issue 8 years ago • 4 comments

Hi, I found a problem in compute-cifar10-mean.py#L31.

The shape of torchvision.datasets.CIFAR10.train_data should be (50000, 32, 32, 3) instead of (50000, 3, 32, 32), so the code in line#31 should be pixels = data[:,:,:,i].ravel()

xuyan1115 avatar Aug 08 '17 07:08 xuyan1115

When you load the data with the "ToTensor()" transform on as is done by the author, it loads the data as BCHW, so the code is correct.

gsp-27 avatar Aug 23 '17 02:08 gsp-27

@gsp-27, when I read the source code of loading CIFAR10 dataset, I found that the param of transform is just used in the function __getitem__(self, index), which means that only calling self[index] , the output's format is BCHW.

BTW, when I ran compute-cifar10-mean.py, the shape of data is BHWC indeed.

xuyan1115 avatar Aug 23 '17 04:08 xuyan1115

same problem, I think compute-cifar10-mean.py#L31 did has a mistake BTW I found the mean and std computed by the script here is different from demo.py in line212 and line213, it confuses me, does anyone know why? Thanks!

zhaofenqiang avatar Nov 21 '17 13:11 zhaofenqiang

@zhaofenqiang Following my suggestion, you should modify compute-cifar10-mean.py#L31 to pixels = data[:,:,:,i].ravel(), and the result is same as demo.py.

xuyan1115 avatar Dec 11 '17 06:12 xuyan1115