0PricingLogin
Learn AI with Python · Lesson

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, DataLoader

The 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

  1. PyTorch Tensors and Autograd
  2. Custom Datasets and DataLoaders
  3. Building and Training CNNs in PyTorch
  4. Object Detection with YOLOv8
← Back to Learn AI with Python