Dataset
In PyTorch, Dataset is an abstraction for an indexed collection of samples that supports retrieving individual items and, typically, reporting its size.
Inside Deep Learning: Math, Algorithms, Models
- How it is used
- Organizes indexed input–target samples for neural-network training and hands sample selection to a DataLoader.
- How deep it goes
- Implements __getitem__ and __len__, explains on-demand preparation, and extends the pattern to regression, classification, and segmentation.
- Examples
- Uses MNIST rows, one-dimensional regression, two-class moons data, and nuclei images with combined masks.
- What you can do after
- Build it from scratch with indexed retrieval and size methods, or apply it via TensorDataset when the data fits in RAM.
Read how Inside Deep Learning: Math, Algorithms, Models explains Dataset →
Fight Fraud with Machine Learning
Dataset is a PyTorch base class defining an interface for indexed collections of training examples.
- How it is used
- Structures indexed images, masks, audio waveforms, features, and labels for PyTorch training, validation, and testing pipelines.
- 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 you can do after
- Build it from scratch by subclassing Dataset, indexing samples, applying preprocessing, and returning inputs with labels.
Read how Fight Fraud with Machine Learning explains Dataset →
Also covered in
- Rearchitecting LLMsIn early access (MEAP)
- Causal AI
What to know first
- language modelA language model is a computational model that represents patterns in linguistic sequences to assign probabilities, predict, generate, or evaluate language.
- machine learningMachine learning is a field of computational methods in which systems learn patterns or relationships from data to make predictions, decisions, or other outputs.
- optimizationOptimization is the systematic selection or modification of values, configurations, or implementations to improve a defined objective, often subject to constraints.
- generationGeneration is the production of an output by a computational model from supplied input or context, often using patterns learned from data.
Related concepts
- DataLoaderused by · PyTorch DataLoader is an iterable utility that provides samples from a dataset, with support for batching, sampling, and optional shuffling or parallel loading.
- distillationused by · Distillation is a training technique in which a student model learns to approximate the outputs or behavior of a teacher model.
- __getitem__implements · __getitem__ is a Python special method that defines subscription access to an object's elements using square-bracket notation.
- __len__implements · __len__ is a Python special method that returns an object’s nonnegative integer length for use by the len() built-in.
- synthetic dataincludes · Synthetic data is artificially generated data designed to represent selected characteristics, scenarios, or distributions of a target domain or process.
Questions about Dataset
What is Dataset?
In PyTorch, Dataset is an abstraction for an indexed collection of samples that supports retrieving individual items and, typically, reporting its size.
Which Manning books explain Dataset?
Inside Deep Learning: Math, Algorithms, Models and Fight Fraud with Machine Learning.
What should I know before learning Dataset?
Manning books that teach Dataset usually introduce language model, machine learning, optimization and generation first.
What kinds of Dataset are there?
Kinds of Dataset include synthetic data.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

