pub struct GroupNorm {
pub num_groups: usize,
pub num_channels: usize,
pub eps: f64,
pub gamma: ArrayD<f64>,
pub beta: ArrayD<f64>,
pub affine: bool,
}Expand description
Group Normalization: divides channels into groups and normalizes within each group.
Input shape: [batch, channels, ...spatial_dims...]
Fields§
§num_groups: usizeNumber of groups to divide channels into.
num_channels: usizeTotal number of channels.
eps: f64Small constant for numerical stability.
gamma: ArrayD<f64>Learnable scale parameter [channels].
beta: ArrayD<f64>Learnable shift parameter [channels].
affine: boolWhether to apply learnable affine transformation.
Implementations§
Source§impl GroupNorm
impl GroupNorm
Sourcepub fn new(
num_groups: usize,
num_channels: usize,
eps: f64,
affine: bool,
) -> Result<Self, NormalizationError>
pub fn new( num_groups: usize, num_channels: usize, eps: f64, affine: bool, ) -> Result<Self, NormalizationError>
Create a new GroupNorm layer.
num_channels must be evenly divisible by num_groups.
Sourcepub fn forward(
&self,
input: &ArrayD<f64>,
) -> Result<ArrayD<f64>, NormalizationError>
pub fn forward( &self, input: &ArrayD<f64>, ) -> Result<ArrayD<f64>, NormalizationError>
Forward pass: normalize within each group.
Input shape: [batch, channels, ...spatial_dims...] (at least 2-D).
Sourcepub fn channels_per_group(&self) -> usize
pub fn channels_per_group(&self) -> usize
Number of channels per group.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for GroupNorm
impl RefUnwindSafe for GroupNorm
impl Send for GroupNorm
impl Sync for GroupNorm
impl Unpin for GroupNorm
impl UnsafeUnpin for GroupNorm
impl UnwindSafe for GroupNorm
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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