Template Class Dataset

Inheritance Relationships

Base Type

Class Documentation

template<typename Self, typename SingleExample = Example<>>
class torch::data::datasets::Dataset : public torch::data::datasets::BatchDataset<Self, std::vector<SingleExample>>

A dataset that can yield data in batches, or as individual examples.

A Dataset is a BatchDataset, because it supports random access and therefore batched access is implemented (by default) by calling the random access indexing function for each index in the requested batch of indices. This can be customized.

Public Types

using ExampleType = SingleExample

Public Functions

ExampleType get(size_t index) = 0

Returns the example at the given index.

std::vector<ExampleType> get_batch(ArrayRef<size_t> indices) override

Returns a batch of data.

The default implementation calls get() for every requested index in the batch.


Access comprehensive developer documentation for PyTorch

View Docs


Get in-depth tutorials for beginners and advanced developers

View Tutorials


Find development resources and get your questions answered

View Resources