pub struct LayerNorm {
pub weight: Option<Array>,
pub bias: Option<Array>,
pub eps: f32,
}Expand description
Layer normalisation over the last axis, optionally with a learned scale and bias
(MLX’s nn.LayerNorm, the fused fast::layer_norm).
Fields§
§weight: Option<Array>The scale, [dims] (ones), if affine.
bias: Option<Array>The shift, [dims] (zeros), if affine with a bias.
eps: f32Added to the variance.
Implementations§
Trait Implementations§
Source§impl Module for LayerNorm
impl Module for LayerNorm
Source§fn visit(&mut self, p: &mut Parameters<'_>)
fn visit(&mut self, p: &mut Parameters<'_>)
Reports every parameter and submodule to
p, frozen ones included.Source§fn parameters(&self) -> Vec<(String, Array)>
fn parameters(&self) -> Vec<(String, Array)>
Every parameter with its path (
layers.0.weight), in visiting order.Source§fn trainable_parameters(&self) -> Vec<(String, Array)>
fn trainable_parameters(&self) -> Vec<(String, Array)>
The parameters that are trained (not frozen), with their paths.
Source§fn update_trainable(&mut self, values: &[Array]) -> Result<()>
fn update_trainable(&mut self, values: &[Array]) -> Result<()>
Replaces the trainable parameters, given in the order of
Module::trainable_parameters (as optimizers return them).Source§fn load_weights(
&mut self,
weights: impl IntoIterator<Item = (String, Array)>,
strict: bool,
) -> Result<()>
fn load_weights( &mut self, weights: impl IntoIterator<Item = (String, Array)>, strict: bool, ) -> Result<()>
Replaces parameters by path, as MLX’s
load_weights: each weight must have its
parameter’s shape (the dtype is kept as loaded). With strict, every parameter
must be given and no unknown names are allowed.Auto Trait Implementations§
impl Freeze for LayerNorm
impl RefUnwindSafe for LayerNorm
impl Send for LayerNorm
impl Sync for LayerNorm
impl Unpin for LayerNorm
impl UnsafeUnpin for LayerNorm
impl UnwindSafe for LayerNorm
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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