Template Class Transform

Inheritance Relationships

Base Type

Derived Type

Class Documentation

template<typename Input, typename Output>
class torch::data::transforms::Transform : public torch::data::transforms::BatchTransform<std::vector<Input>, std::vector<Output>>

A transformation of individual input examples to individual output examples.

Just like a Dataset is a BatchDataset, a Transform is a BatchTransform that can operate on the level of individual examples rather than entire batches. The batch-level transform is implemented (by default) in terms of the example-level transform, though this can be customized.

Subclassed by torch::data::transforms::Lambda< Input, Output >

Public Types

using InputType = Input
using OutputType = Output

Public Functions

OutputType apply(InputType input) = 0

Applies the transformation to the given input.

std::vector<Output> apply_batch(std::vector<Input> input_batch) override

Applies the transformation over the entire input_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