Custom Datasets and DataLoaders
torch.utils.data.Dataset, __len__/__getitem__, DataLoader, transforms, augmentation.
Feeding Data to a Model
Training needs an efficient way to read, transform, and batch data. PyTorch provides two abstractions: Dataset (knows how to fetch one sample) and DataLoader (batches and shuffles them).
from torch.utils.data import Dataset, DataLoaderThe Dataset Interface
A custom Dataset subclass must implement two methods: __len__ (how many samples) and __getitem__ (return the sample at an index). PyTorch calls these to pull data.
All lessons in this course
- PyTorch Tensors and Autograd
- Custom Datasets and DataLoaders
- Building and Training CNNs in PyTorch
- Object Detection with YOLOv8