pub struct Normalize { /* private fields */ }Expand description
Normalizes a tensor with mean and standard deviation.
Supports both scalar normalization (applied uniformly) and per-channel
normalization (PyTorch-style transforms.Normalize(mean=[...], std=[...])).
For per-channel mode, the tensor is expected to have shape [C, H, W] or
[N, C, H, W].
Implementations§
Source§impl Normalize
impl Normalize
Sourcepub fn new(mean: f32, std: f32) -> Self
pub fn new(mean: f32, std: f32) -> Self
Creates a new scalar Normalize transform (applied uniformly to all elements).
Sourcepub fn per_channel(mean: Vec<f32>, std: Vec<f32>) -> Self
pub fn per_channel(mean: Vec<f32>, std: Vec<f32>) -> Self
Creates a per-channel Normalize transform (PyTorch-compatible).
For a [C, H, W] tensor, mean and std must have length C.
Each channel is normalized independently: output[c] = (input[c] - mean[c]) / std[c].
Sourcepub fn standard() -> Self
pub fn standard() -> Self
Creates a Normalize for standard normal distribution (mean=0, std=1).
Sourcepub fn zero_centered() -> Self
pub fn zero_centered() -> Self
Creates a Normalize for [0,1] to [-1,1] conversion (mean=0.5, std=0.5).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Normalize
impl RefUnwindSafe for Normalize
impl Send for Normalize
impl Sync for Normalize
impl Unpin for Normalize
impl UnsafeUnpin for Normalize
impl UnwindSafe for Normalize
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more