pub struct BatchNorm1d<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 2-D [N, C] or 3-D [N, C, L] input.
During training the per-batch mean and variance are used; the running statistics are updated with exponential moving average. During inference the frozen running statistics are used instead.
Parameters:
num_features— number of channels Ceps— numerical stability constant added to the variancemomentum— weight of the current batch in the running-stats EMAaffine— if true, learns per-channel γ (weight) and β (bias)track_running_stats— if true, maintains running_mean / running_var
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> BatchNorm1d<D, IT, OT, RANK>
impl<D: Dtype, IT, OT, const RANK: usize> BatchNorm1d<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.