Shortcuts

Template Class BatchDataset

Inheritance Relationships

Derived Types

Class Documentation

template<typename Self, typename Batch = std::vector<Example<>>, typename BatchRequest = ArrayRef<size_t>>
class BatchDataset

A dataset that can yield data only in batches.

Subclassed by torch::data::datasets::Dataset< MNIST >, torch::data::datasets::Dataset< TensorDataset, TensorExample >, torch::data::datasets::StatefulDataset< ChunkDataset< ChunkReader, samplers::RandomSampler, samplers::RandomSampler >, ChunkReader::BatchType, size_t >

Public Types

using SelfType = Self
using BatchType = Batch
using BatchRequestType = BatchRequest

Public Functions

virtual ~BatchDataset() = default
virtual Batch get_batch(BatchRequest request) = 0

Returns a batch of data given an index.

virtual std::optional<size_t> size() const = 0

Returns the size of the dataset, or an empty std::optional if it is unsized.

template<typename TransformType>
inline MapDataset<Self, TransformType> map(TransformType transform) &

Creates a MapDataset that applies the given transform to this dataset.

template<typename TransformType>
inline MapDataset<Self, TransformType> map(TransformType transform) &&

Creates a MapDataset that applies the given transform to this dataset.

Public Static Attributes

static constexpr bool is_stateful = detail::is_optional<BatchType>::value

Docs

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources