Shortcuts

Template Class MapDataset

Inheritance Relationships

Base Type

  • public torch::data::datasets::BatchDataset< MapDataset< SourceDataset, AppliedTransform >, detail::optional_if_t< SourceDataset::is_stateful, AppliedTransform::OutputBatchType >, SourceDataset::BatchRequestType > (Template Class BatchDataset)

Class Documentation

template<typename SourceDataset, typename AppliedTransform>
class torch::data::datasets::MapDataset : public torch::data::datasets::BatchDataset<MapDataset<SourceDataset, AppliedTransform>, detail::optional_if_t<SourceDataset::is_stateful, AppliedTransform::OutputBatchType>, SourceDataset::BatchRequestType>

A MapDataset is a dataset that applies a transform to a source dataset.

Public Types

using DatasetType = SourceDataset
using TransformType = AppliedTransform
using BatchRequestType = typename SourceDataset::BatchRequestType
using OutputBatchType = detail::optional_if_t<SourceDataset::is_stateful, typename AppliedTransform::OutputBatchType>

Public Functions

MapDataset(DatasetType dataset, TransformType transform)
OutputBatchType get_batch(BatchRequestType indices) override

Gets a batch from the source dataset and applies the transform to it, returning the result.

optional< size_t > size () const noexceptoverride

Returns the size of the source dataset.

void reset()

Calls reset() on the underlying dataset.

NOTE: Stateless datasets do not have a reset() method, so a call to this method will only compile for stateful datasets (which have a reset() method).

const SourceDataset &dataset() noexcept

Returns the underlying dataset.

const AppliedTransform &transform() noexcept

Returns the transform being applied.

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