diff --git a/docs/source/models.rst b/docs/source/models.rst index 097df73f93f..d8f9d7a9643 100644 --- a/docs/source/models.rst +++ b/docs/source/models.rst @@ -86,6 +86,28 @@ You can use the following transform to normalize:: An example of such normalization can be found in the imagenet example `here `_ +The process for obtaining the values of `mean` and `std` is roughly equivalent +to:: + + import torch + from torchvision import datasets, transforms as T + + transform = T.Compose([T.Resize(256), T.CenterCrop(224), T.ToTensor()]) + dataset = datasets.ImageNet(".", split="train", transform=transform) + + means = [] + stds = [] + for img in subset(dataset): + means.append(torch.mean(img)) + stds.append(torch.std(img)) + + mean = torch.mean(torch.tensor(means)) + std = torch.mean(torch.tensor(stds)) + +Unfortunately, the concret `subset` that was used is lost. For more +information see `this discussion `_ +or `these experiments `_. + ImageNet 1-crop error rates (224x224) ================================ ============= =============