mirror of
https://github.com/pytorch/pytorch.git
synced 2026-10-28 18:56:51 +08:00
The fix-cpp-build branch is a major restructuring that: - Drops Exhale (which auto-generated API docs but caused OOM in CI) in favor of hand-written RST pages using Breathe directives - Reorganizes notes into a hierarchical API reference with proper categories - Adds new content: XPU docs, stable ABI docs, DeviceGuard/Stream docs - Always runs Doxygen instead of gating on an env var Pull Request resolved: https://github.com/pytorch/pytorch/pull/174096 Approved by: https://github.com/janeyx99, https://github.com/seemethere, https://github.com/albanD
1.9 KiB
1.9 KiB
myst
| myst | ||||||
|---|---|---|---|---|---|---|
|
Transforms
Transforms apply preprocessing to data samples, such as normalization or
augmentation. They can be chained using the .map() method on datasets.
Transform (Base Class)
The base class for all transforms. Subclass this to create custom transforms.
:members:
:undoc-members:
BatchTransform (Base Class)
Base class for transforms that operate on entire batches.
:members:
:undoc-members:
TensorTransform
Base class for transforms that operate on tensors specifically.
:members:
:undoc-members:
Normalize
Normalizes tensors with a given mean and standard deviation.
:members:
:undoc-members:
Stack
Stacks a batch of tensors into a single tensor.
:members:
:undoc-members:
Example:
auto dataset = torch::data::datasets::MNIST("./data")
.map(torch::data::transforms::Normalize<>(0.5, 0.5))
.map(torch::data::transforms::Stack<>());
Lambda
:members:
:undoc-members:
TensorLambda
:members:
:undoc-members:
BatchLambda
:members:
:undoc-members:
Chaining Transforms
Transforms can be chained together using .map():
auto dataset = torch::data::datasets::MNIST("./data")
.map(torch::data::transforms::Normalize<>(0.1307, 0.3081))
.map(torch::data::transforms::Stack<>());