A training dataset is the portion of data supplied to a model so it can learn parameters or representations. It may contain translations, images and labels, image–caption pairs, or text–image pairs. Training data differs from test data, which is held out for evaluation. section 2.4 section 3.2.2
Prepare a training dataset by moving from raw records to model-ready batches:
- Select examples and associated targets, such as German–English translations, clothing labels, or image–caption pairs. section 2.4 section 4.1
- Standardize inputs: convert images to tensors, resize them, normalize their ranges, and tokenize captions or labels when needed. section 3.2.2 section 4.1.1
- Create training targets aligned with the task. Captioning shifts tokens by one position, while denoising compares predicted noise with injected ground-truth noise. section 4.1.1 section 5.3.1
- Increase usable variety with image augmentation, then batch and shuffle examples for training. section 3.2.2 section 6.3.3
- Keep test examples separate and apply compatible preprocessing without training-only augmentation. section 3.2.2 section 4.2
Image captioning
Flickr 8k supplies roughly 8,000 images with five human captions per image. A preparation pipeline resizes images to 3 × 128 × 128, tokenizes captions, adds <start> and <end>, and turns “two bears fight” into input [<start>, two, bears, fight] and target [two, bears, fight, <end>]. section 4.1.1 section 4.2.1
Diffusion training
A FashionMNIST training dataset contains grayscale clothing images and labels for ten clothing categories. Images are converted to tensors, normalized to [-1, 1], batched, noised at randomly selected time steps, and passed to a denoising U-Net whose error updates its parameters. section 6.3.3 section 5.3.1
import torchvision.transforms as transforms
trainset.transform = transforms.Compose(
[transforms.ToTensor(),
transforms.Resize((32, 32),antialias=True),
transforms.RandomHorizontalFlip(p=0.5),
transforms.RandomResizedCrop((32, 32), scale=(0.8, 1.0),
ratio=(0.75, 1.3333333333333333),
interpolation=2,antialias=True),
transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))])
Inspect a PyTorch transformation pipeline that converts images to tensors, resizes and augments them, then normalizes their values for training. section 3.2.2



































