File tree 1 file changed +22
-0
lines changed 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -86,6 +86,28 @@ You can use the following transform to normalize::
86
86
An example of such normalization can be found in the imagenet example
87
87
`here <https://github.com/pytorch/examples/blob/42e5b996718797e45c46a25c55b031e6768f8440/imagenet/main.py#L89-L101 >`_
88
88
89
+ The process for obtaining the values of `mean ` and `std ` is roughly equivalent
90
+ to::
91
+
92
+ import torch
93
+ from torchvision import datasets, transforms as T
94
+
95
+ transform = T.Compose([T.Resize(256), T.CenterCrop(224), T.ToTensor()])
96
+ dataset = datasets.ImageNet(".", split="train", transform=transform)
97
+
98
+ means = []
99
+ stds = []
100
+ for img in subset(dataset):
101
+ means.append(torch.mean(img))
102
+ stds.append(torch.std(img))
103
+
104
+ mean = torch.mean(torch.tensor(means))
105
+ std = torch.mean(torch.tensor(stds))
106
+
107
+ Unfortunately, the concret `subset ` that was used is lost. For more
108
+ information see `this discussion <https://github.com/pytorch/vision/issues/1439 >`_
109
+ or `these experiments <https://github.com/pytorch/vision/pull/1965 >`_.
110
+
89
111
ImageNet 1-crop error rates (224x224)
90
112
91
113
================================ ============= =============
You can’t perform that action at this time.
0 commit comments