pub struct LayerNorm {
pub dimensions: i32,
pub eps: f32,
pub weight: Param<Option<Array>>,
pub bias: Param<Option<Array>>,
}Expand description
Fields§
§dimensions: i32Number of features in the input
eps: f32Value added to the denominator for numerical stability.
weight: Param<Option<Array>>An optional trainable weight
bias: Param<Option<Array>>An optional trainable bias
Implementations§
Source§impl LayerNorm
impl LayerNorm
Sourcepub const DEFAULT_EPS: f32 = 1e-5
pub const DEFAULT_EPS: f32 = 1e-5
Default value for eps.
Sourcepub const DEFAULT_AFFINE: bool = true
pub const DEFAULT_AFFINE: bool = true
Enable trainable weight and bias by default.
Trait Implementations§
Source§impl Buildable for LayerNorm
impl Buildable for LayerNorm
Source§type Builder = LayerNormBuilder
type Builder = LayerNormBuilder
The builder type for this buildable type
Source§impl Builder<LayerNorm> for LayerNormBuilder
impl Builder<LayerNorm> for LayerNormBuilder
Source§impl Module<&Array> for LayerNorm
impl Module<&Array> for LayerNorm
Source§fn training_mode(&mut self, _mode: bool)
fn training_mode(&mut self, _mode: bool)
Set whether the module is in training mode. Read more
Source§impl ModuleParameters for LayerNorm
impl ModuleParameters for LayerNorm
Source§fn num_parameters(&self) -> usize
fn num_parameters(&self) -> usize
Get the total number of parameters in the module. Read more
Source§fn freeze_parameters(&mut self, recursive: bool)
fn freeze_parameters(&mut self, recursive: bool)
Freeze all parameters in the module.
Source§fn unfreeze_parameters(&mut self, recursive: bool)
fn unfreeze_parameters(&mut self, recursive: bool)
Unfreeze all parameters in the module.
Source§fn parameters(&self) -> ModuleParamRef<'_>
fn parameters(&self) -> ModuleParamRef<'_>
Get references to the module parameters.
Source§fn parameters_mut(&mut self) -> ModuleParamMut<'_>
fn parameters_mut(&mut self) -> ModuleParamMut<'_>
Get mutable references to the module parameters.
Source§fn trainable_parameters(&self) -> ModuleParamRef<'_>
fn trainable_parameters(&self) -> ModuleParamRef<'_>
Get references to the trainable parameters. A parameter is trainable if it is NOT frozen.
Source§fn all_frozen(&self) -> Option<bool>
fn all_frozen(&self) -> Option<bool>
Check if all parameters in the module are frozen. Returns
None if there are no parameters.Source§fn any_frozen(&self) -> Option<bool>
fn any_frozen(&self) -> Option<bool>
Check if any parameter in the module is frozen. Returns
None if there are no parameters.Source§fn update(&mut self, parameters: ModuleParam)
fn update(&mut self, parameters: ModuleParam)
Update the module parameters.
Source§fn update_flattened(&mut self, flattened_parameters: FlattenedModuleParam)
fn update_flattened(&mut self, flattened_parameters: FlattenedModuleParam)
Update the module parameters from a flattened representation.
Auto Trait Implementations§
impl !Sync for LayerNorm
impl Freeze for LayerNorm
impl RefUnwindSafe for LayerNorm
impl Send for LayerNorm
impl Unpin for LayerNorm
impl UnsafeUnpin for LayerNorm
impl UnwindSafe for LayerNorm
Blanket Implementations§
impl<M> Activation for M
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 moreSource§impl<T> IntoOption<T> for T
impl<T> IntoOption<T> for T
Source§fn into_option(self) -> Option<T>
fn into_option(self) -> Option<T>
Convert into an
Option.Source§impl<T> IntoStrideBy for T
impl<T> IntoStrideBy for T
Source§impl<T> ModuleParametersExt for Twhere
T: ModuleParameters,
impl<T> ModuleParametersExt for Twhere
T: ModuleParameters,
Source§impl<T> Parameter for Twhere
T: ModuleParameters,
impl<T> Parameter for Twhere
T: ModuleParameters,
Source§fn is_frozen(&self) -> Option<bool>
fn is_frozen(&self) -> Option<bool>
Check if the parameter is frozen. Returns
None if the parameter is a module that has no
parameters.Source§fn as_nested_value(&self) -> NestedValue<Rc<str>, &Array>
fn as_nested_value(&self) -> NestedValue<Rc<str>, &Array>
Get the parameter as a nested value.
Source§fn as_nested_value_mut(&mut self) -> NestedValue<Rc<str>, &mut Array>
fn as_nested_value_mut(&mut self) -> NestedValue<Rc<str>, &mut Array>
Get the parameter as a mutable nested value.
Source§fn as_trainable_nested_value(&self) -> Option<NestedValue<Rc<str>, &Array>>
fn as_trainable_nested_value(&self) -> Option<NestedValue<Rc<str>, &Array>>
Get the parameter as a nested value if it is trainable.
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
impl<T> SequentialModuleItem for Twhere
T: UnaryModule + Debug,
impl<T> UnaryModule for T
Source§impl<T> Updatable for Twhere
T: ModuleParameters,
impl<T> Updatable for Twhere
T: ModuleParameters,
Source§fn state_projection(
&mut self,
) -> Result<StateProjection<'_>, StateProjectionError>
fn state_projection( &mut self, ) -> Result<StateProjection<'_>, StateProjectionError>
Declare all required and optional state slots.