liveBook · Manning

Dataset

As explained in Fight Fraud with Machine Learning

Dataset is a PyTorch base class defining an interface for indexed collections of training examples.

Dataset is a PyTorch base class for representing indexed collections of training examples and labels. A model-training pipeline uses it to turn stored receipts, images, audio files, or extracted features into samples that can be retrieved by index. section 6.3 section 8.1.3

A custom Dataset typically provides:

The dataset supplies individual samples; DataLoader supplies batching, shuffling, and parallel loading. Separate Dataset objects can represent training, validation, and test splits before model training and evaluation. section 6.3 section 8.1.3

Receipt forgery segmentation

A SegmentationDataset reads a receipt image, creates a binary mask from forgery bounding boxes, resizes the image and mask, converts the mask to an integer tensor, and returns both. DeepLabV3 can then classify each pixel as genuine or forged. section 6.3.1 section 6.3

Real-versus-fake audio

An AudioDataset indexes WAV files under real and fake directories. For a requested index, it loads the waveform, extracts MFCC features through a transform, converts the class name to an integer, and returns the feature-label pair. section 8.1.3

How Fight Fraud with Machine Learning covers it

How deep it goes
Defines and implements __init__, __len__, and __getitem__, while delegating batching and parallel loading to DataLoader.
Examples
Uses receipt images with forgery masks and WAV files labeled real or fake as concrete indexed collections.
What it assumes
Assumes basic Python and PyTorch familiarity while demonstrating file indexing, image or audio loading, preprocessing, and label preparation.
What you can do after
Build it from scratch by subclassing Dataset, indexing samples, applying preprocessing, and returning inputs with labels.
How it connects
Connects PyTorch transforms, DataLoader, image segmentation, MFCC features, binary classification, and transformer models.

Also explained in

Compare how 2 books explain Dataset →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Fight Fraud with Machine Learning. The section links point to the parts of the book it draws on.