# MNIST mean and std

**URL:** <https://community.deeplearning.ai/t/mnist-mean-and-std/883455>\
**Category:** PyTorch: Fundamentals\
**Tags:** dl-ai-learning-platform, week-module-2\
**Created:** [November 16, 2025, 1:59pm UTC](https://community.deeplearning.ai/t/mnist-mean-and-std/883455 "2025-11-16T13:59:51Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![balaji.ambresh](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/balaji.ambresh/32/128697_2.png) [@balaji.ambresh](https://community.deeplearning.ai/u/balaji.ambresh)\
**Post date:** [November 16, 2025, 4:12pm UTC](https://community.deeplearning.ai/t/mnist-mean-and-std/883455/3 "2025-11-16T16:12:05Z")

</div>

The values are the mean and standard deviation of the training split of MNIST.

```python
import torch
from torchvision import datasets, transforms

transform = transforms.Compose([transforms.ToTensor()])
trainset = datasets.MNIST('mnist_train', train=True, download=True, transform=transform)
images = torch.stack(list(data[0] for data in trainset), dim=0)

print(images.shape) # torch.Size([60000, 1, 28, 28])
print(images.mean()) # tensor(0.1307)
print(images.std()) # tensor(0.3081)

```

---

_[View the full topic](https://community.deeplearning.ai/t/mnist-mean-and-std/883455)._
