Created
June 22, 2018 13:48
-
-
Save weiaicunzai/e623931921efefd4c331622c344d8151 to your computer and use it in GitHub Desktop.
compute cifar100 mean and std
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def compute_mean_std(cifar100_dataset): | |
"""compute the mean and std of cifar100 dataset | |
Args: | |
cifar100_training_dataset or cifar100_test_dataset | |
witch derived from class torch.utils.data | |
Returns: | |
a tuple contains mean, std value of entire dataset | |
""" | |
data_r = numpy.dstack([cifar100_dataset[i][1][:, :, 0] for i in range(len(cifar100_dataset))]) | |
data_g = numpy.dstack([cifar100_dataset[i][1][:, :, 1] for i in range(len(cifar100_dataset))]) | |
data_b = numpy.dstack([cifar100_dataset[i][1][:, :, 2] for i in range(len(cifar100_dataset))]) | |
mean = numpy.mean(data_r), numpy.mean(data_g), numpy.mean(data_b) | |
std = numpy.std(data_r), numpy.std(data_g), numpy.std(data_b) | |
return mean, std |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Do you have one for stl-10 and imagenet?