CIFAR-10 is a labeled benchmark of 60,000 tiny color images arranged into 10 object categories, including planes, cars, birds, and cats. Each image measures 3 × 32 × 32: three color channels and 32-pixel height and width. section 3.0 section 3.1.2
A practical CIFAR-10 workflow includes:
- Download separate training and test subsets. section 3.2 section 3.2.1
- Represent class numbers 0 through 9 as names such as plane, car, bird, cat, deer, dog, frog, horse, ship, and truck. section 3.2.1
- Batch labeled image examples for training and inspect samples visually. section 3.2 section 3.2.1
- Split each image into an 8 × 8 grid of 64 patches when preparing it for a vision transformer. section 3.1.2
Training a vision transformer
A ViT converts each 32 × 32 image into 64 patches, prepends a class token, and represents the result as a 65 × 48 sequence. It adds positional encodings, predicts one of 10 labels, and minimizes cross-entropy loss. section 3.1.1 section 3.1.2
import torchvision
trainset=torchvision.datasets.CIFAR10(root=r'.',
train=True, download=True)
Use the torchvision dataset loader to download the CIFAR-10 training set directly, then inspect labeled images with the provided class-name mapping and plotting pattern. section 3.2.1

