Skip to content

Instantly share code, notes, and snippets.

@chrisliu298
Created March 5, 2022 19:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrisliu298/4e78d31aaa9791755723f660891a81db to your computer and use it in GitHub Desktop.
Save chrisliu298/4e78d31aaa9791755723f660891a81db to your computer and use it in GitHub Desktop.
import numpy as np
from torchvision import datasets
train_dataset = datasets.CIFAR10("/tmp/data", train=True, download=True)
train_images = [np.array(train_dataset[i][0]) for i in range(len(train_dataset))]
train_images = np.stack(train_images)
means = (
np.array(
[
np.mean(train_images[:, :, :, 0]),
np.mean(train_images[:, :, :, 1]),
np.mean(train_images[:, :, :, 2]),
]
)
/ 255
)
stds = (
np.array(
[
np.std(train_images[:, :, :, 0]),
np.std(train_images[:, :, :, 1]),
np.std(train_images[:, :, :, 2]),
]
)
/ 255
)
print(means)
print(stds)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment