pub struct BatchNorm2dLayer { /* private fields */ }Expand description
2D batch normalization layer (NHWC layout).
Supports both inference-mode (raw tensor) and graph-mode (autograd training). Stores learned gamma/beta and running mean/variance.
Implementations§
Source§impl BatchNorm2dLayer
impl BatchNorm2dLayer
pub fn new( num_features: usize, epsilon: f32, gamma: Tensor, beta: Tensor, running_mean: Tensor, running_var: Tensor, ) -> Result<Self, ModelError>
Sourcepub fn identity_init(
num_features: usize,
epsilon: f32,
) -> Result<Self, ModelError>
pub fn identity_init( num_features: usize, epsilon: f32, ) -> Result<Self, ModelError>
Unit-scale/zero-shift initialization with zero running statistics.
Sourcepub fn register_params(&mut self, graph: &mut Graph)
pub fn register_params(&mut self, graph: &mut Graph)
Registers gamma/beta as graph variables (trainable), running stats as constants.
pub fn sync_from_graph(&mut self, graph: &Graph) -> Result<(), ModelError>
pub fn num_features(&self) -> usize
pub fn epsilon(&self) -> f32
pub fn gamma(&self) -> &Tensor
pub fn beta(&self) -> &Tensor
pub fn running_mean(&self) -> &Tensor
pub fn running_var(&self) -> &Tensor
pub fn gamma_mut(&mut self) -> &mut Tensor
pub fn beta_mut(&mut self) -> &mut Tensor
pub fn running_mean_mut(&mut self) -> &mut Tensor
pub fn running_var_mut(&mut self) -> &mut Tensor
pub fn gamma_node(&self) -> Option<NodeId>
pub fn beta_node(&self) -> Option<NodeId>
pub fn forward( &self, graph: &mut Graph, input: NodeId, ) -> Result<NodeId, ModelError>
pub fn forward_inference(&self, input: &Tensor) -> Result<Tensor, ModelError>
Trait Implementations§
Source§impl Clone for BatchNorm2dLayer
impl Clone for BatchNorm2dLayer
Source§fn clone(&self) -> BatchNorm2dLayer
fn clone(&self) -> BatchNorm2dLayer
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for BatchNorm2dLayer
impl Debug for BatchNorm2dLayer
Source§impl PartialEq for BatchNorm2dLayer
impl PartialEq for BatchNorm2dLayer
impl StructuralPartialEq for BatchNorm2dLayer
Auto Trait Implementations§
impl Freeze for BatchNorm2dLayer
impl RefUnwindSafe for BatchNorm2dLayer
impl Send for BatchNorm2dLayer
impl Sync for BatchNorm2dLayer
impl Unpin for BatchNorm2dLayer
impl UnsafeUnpin for BatchNorm2dLayer
impl UnwindSafe for BatchNorm2dLayer
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