pub trait Transform: Send + Sync {
// Required methods
fn apply(&self, sample: Sample) -> TransformResult;
fn name(&self) -> &str;
}Expand description
A stateless transform that operates on individual samples.
For stateful operations (shuffle, batch), use StatefulTransform.
§Implementing a Transform
use tenshift_core::transform::{Transform, TransformResult};
use tenshift_core::sample::Sample;
struct Normalize {
mean: f32,
std: f32,
}
impl Transform for Normalize {
fn apply(&self, sample: Sample) -> TransformResult {
// Normalize a tensor field in-place
TransformResult::Sample(sample)
}
fn name(&self) -> &str {
"normalize"
}
}Required Methods§
Sourcefn apply(&self, sample: Sample) -> TransformResult
fn apply(&self, sample: Sample) -> TransformResult
Apply this transform to a sample.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".