pub struct BatchNorm2d<D: Dtype, IT, OT, const RANK: usize> {
pub num_features: usize,
pub eps: f64,
pub momentum: f64,
pub affine: bool,
pub track_running_stats: bool,
/* private fields */
}Expand description
Batch normalisation over a 4-D [N, C, H, W] input.
Applies the same statistics as BatchNorm1d but treats each (C) channel
independently across the (N, H, W) axes.
Fields§
§num_features: usizeNumber of channels/features.
eps: f64Numerical stability constant added to the variance.
momentum: f64Weight of the current batch in the running-stats exponential moving average.
affine: boolWhether to learn per-channel scale (gamma) and shift (beta) parameters.
track_running_stats: boolWhether to maintain running mean/variance across batches.
Implementations§
Source§impl<D: Dtype, IT, OT, const RANK: usize> BatchNorm2d<D, IT, OT, RANK>
impl<D: Dtype, IT, OT, const RANK: usize> BatchNorm2d<D, IT, OT, RANK>
Sourcepub fn new(num_features: usize) -> Self
pub fn new(num_features: usize) -> Self
Creates a new layer with default eps/momentum/affine/track_running_stats.
Sourcepub fn with_momentum(self, momentum: f64) -> Self
pub fn with_momentum(self, momentum: f64) -> Self
Sets the running-stats EMA momentum.
Sourcepub fn with_affine(self, affine: bool) -> Self
pub fn with_affine(self, affine: bool) -> Self
Sets whether to learn per-channel scale/shift parameters.
Sourcepub fn with_track_running_stats(self, track: bool) -> Self
pub fn with_track_running_stats(self, track: bool) -> Self
Sets whether to maintain running mean/variance across batches.
Trait Implementations§
Source§impl<D: Dtype, IT: Tensor<D, RANK> + EagerTensor, OT: Tensor<D, RANK>, const RANK: usize> Layer<IT> for BatchNorm2d<D, IT, OT, RANK>
impl<D: Dtype, IT: Tensor<D, RANK> + EagerTensor, OT: Tensor<D, RANK>, const RANK: usize> Layer<IT> for BatchNorm2d<D, IT, OT, RANK>
Auto Trait Implementations§
impl<D, IT, OT, const RANK: usize> Freeze for BatchNorm2d<D, IT, OT, RANK>
impl<D, IT, OT, const RANK: usize> RefUnwindSafe for BatchNorm2d<D, IT, OT, RANK>
impl<D, IT, OT, const RANK: usize> Send for BatchNorm2d<D, IT, OT, RANK>
impl<D, IT, OT, const RANK: usize> Sync for BatchNorm2d<D, IT, OT, RANK>
impl<D, IT, OT, const RANK: usize> Unpin for BatchNorm2d<D, IT, OT, RANK>
impl<D, IT, OT, const RANK: usize> UnsafeUnpin for BatchNorm2d<D, IT, OT, RANK>
impl<D, IT, OT, const RANK: usize> UnwindSafe for BatchNorm2d<D, IT, OT, RANK>
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