# How to calculate the image dataset's mean and std for deep learning?

Which is correct? Suppose that the image's size is (channels, height, width).

 means = np.zeros(3) stds = np.zeros(3) for image in dataset: image = image.reshape(channels, -1) means += image.mean(1) stds += image.std(1) mean = means / len(dataset) std = stds / len(dataset) 

 images = [image.reshape(channels, -1) for image in dataset] images = np.concatenate(images, 1) mean = images.mean(1) std = images.std(1) 

I googled many times, I still do not find out that how to calculate imagenet's std and mean !

• The second one is correct. – Jan Kukacka Oct 30 '18 at 12:44
• @JanKukacka Any paper supports it? – acgtyrant Oct 30 '18 at 13:23