PyTorch 2 · Autograd and models

Load data in batches

Wrap a dataset to get shuffled mini-batches.

from torch.utils.data import DataLoader

loader = DataLoader(dataset, batch_size=64, shuffle=True)

Official PyTorch 2 documentation

More autograd and models commands

All autograd and models commands · PyTorch 2 cheatsheet

Was this page helpful?