Enum Normalization
#[non_exhaustive]pub enum Normalization<B>where
B: Backend,{
Batch(BatchNorm<B>),
Group(GroupNorm<B>),
Instance(InstanceNorm<B>),
Layer(LayerNorm<B>),
Rms(RmsNorm<B>),
}Expand description
Normalization Layer Wrapper
Provides support for built-in burn::nn::norm norm layers:
Normalization::Batch-BatchNormNormalization::Group-GroupNormNormalization::Instance-InstanceNormNormalization::Layer-LayerNormNormalization::Rms-RmsNorm
The enum is non-exhaustive, to prepare for future additions.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Batch(BatchNorm<B>)
BatchNorm layer.
Group(GroupNorm<B>)
GroupNorm layer.
Instance(InstanceNorm<B>)
[‘InstanceNorm’] layer.
Layer(LayerNorm<B>)
LayerNorm layer.
Rms(RmsNorm<B>)
[‘RmsNorm’] layer.
Implementations§
§impl<B> Normalization<B>where
B: Backend,
impl<B> Normalization<B>where
B: Backend,
pub fn forward<const D: usize>(&self, input: Tensor<B, D>) -> Tensor<B, D>
pub fn forward<const D: usize>(&self, input: Tensor<B, D>) -> Tensor<B, D>
Applies normalization to a tensor.
The normalization contract depends upon the wrapped norm layer; but all norm layers assume an input of at least rank 2; and produce an output of the same rank and shape.
pub fn num_features(&self) -> usize
pub fn num_features(&self) -> usize
Get the number of features.
Trait Implementations§
§impl<B> AutodiffModule<B> for Normalization<B>
impl<B> AutodiffModule<B> for Normalization<B>
§type InnerModule = Normalization<<B as AutodiffBackend>::InnerBackend>
type InnerModule = Normalization<<B as AutodiffBackend>::InnerBackend>
Inner module without auto-differentiation.
§fn valid(&self) -> <Normalization<B> as AutodiffModule<B>>::InnerModule
fn valid(&self) -> <Normalization<B> as AutodiffModule<B>>::InnerModule
Get the same module, but on the inner backend without auto-differentiation.
§impl<B> Clone for Normalization<B>where
B: Backend,
impl<B> Clone for Normalization<B>where
B: Backend,
§fn clone(&self) -> Normalization<B>
fn clone(&self) -> Normalization<B>
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 more§impl<B> Debug for Normalization<B>
impl<B> Debug for Normalization<B>
§impl<B> Display for Normalization<B>where
B: Backend,
impl<B> Display for Normalization<B>where
B: Backend,
§impl<B> From<BatchNorm<B>> for Normalization<B>where
B: Backend,
impl<B> From<BatchNorm<B>> for Normalization<B>where
B: Backend,
§fn from(layer: BatchNorm<B>) -> Normalization<B>
fn from(layer: BatchNorm<B>) -> Normalization<B>
Converts to this type from the input type.
§impl<B> From<GroupNorm<B>> for Normalization<B>where
B: Backend,
impl<B> From<GroupNorm<B>> for Normalization<B>where
B: Backend,
§fn from(layer: GroupNorm<B>) -> Normalization<B>
fn from(layer: GroupNorm<B>) -> Normalization<B>
Converts to this type from the input type.
§impl<B> From<InstanceNorm<B>> for Normalization<B>where
B: Backend,
impl<B> From<InstanceNorm<B>> for Normalization<B>where
B: Backend,
§fn from(layer: InstanceNorm<B>) -> Normalization<B>
fn from(layer: InstanceNorm<B>) -> Normalization<B>
Converts to this type from the input type.
§impl<B> From<LayerNorm<B>> for Normalization<B>where
B: Backend,
impl<B> From<LayerNorm<B>> for Normalization<B>where
B: Backend,
§fn from(layer: LayerNorm<B>) -> Normalization<B>
fn from(layer: LayerNorm<B>) -> Normalization<B>
Converts to this type from the input type.
§impl<B> From<RmsNorm<B>> for Normalization<B>where
B: Backend,
impl<B> From<RmsNorm<B>> for Normalization<B>where
B: Backend,
§fn from(layer: RmsNorm<B>) -> Normalization<B>
fn from(layer: RmsNorm<B>) -> Normalization<B>
Converts to this type from the input type.
§impl<B> Module<B> for Normalization<B>where
B: Backend,
impl<B> Module<B> for Normalization<B>where
B: Backend,
§type Record = NormalizationRecord<B>
type Record = NormalizationRecord<B>
Type to save and load the module.
§fn load_record(
self,
record: <Normalization<B> as Module<B>>::Record,
) -> Normalization<B>
fn load_record( self, record: <Normalization<B> as Module<B>>::Record, ) -> Normalization<B>
Load the module state from a record.
§fn into_record(self) -> <Normalization<B> as Module<B>>::Record
fn into_record(self) -> <Normalization<B> as Module<B>>::Record
Convert the module into a record containing the state.
§fn num_params(&self) -> usize
fn num_params(&self) -> usize
Get the number of parameters the module has, including all of its sub-modules.
§fn visit<Visitor>(&self, visitor: &mut Visitor)where
Visitor: ModuleVisitor<B>,
fn visit<Visitor>(&self, visitor: &mut Visitor)where
Visitor: ModuleVisitor<B>,
Visit each tensor parameter in the module with a visitor.
§fn map<Mapper>(self, mapper: &mut Mapper) -> Normalization<B>where
Mapper: ModuleMapper<B>,
fn map<Mapper>(self, mapper: &mut Mapper) -> Normalization<B>where
Mapper: ModuleMapper<B>,
Map each tensor parameter in the module with a mapper.
§fn collect_devices(
&self,
devices: Vec<<B as Backend>::Device>,
) -> Vec<<B as Backend>::Device>
fn collect_devices( &self, devices: Vec<<B as Backend>::Device>, ) -> Vec<<B as Backend>::Device>
Return all the devices found in the underneath module tree added to the given vector
without duplicates.
§fn to_device(self, device: &<B as Backend>::Device) -> Normalization<B>
fn to_device(self, device: &<B as Backend>::Device) -> Normalization<B>
Move the module and all of its sub-modules to the given device. Read more
§fn fork(self, device: &<B as Backend>::Device) -> Normalization<B>
fn fork(self, device: &<B as Backend>::Device) -> Normalization<B>
Fork the module and all of its sub-modules to the given device. Read more
§fn devices(&self) -> Vec<<B as Backend>::Device>
fn devices(&self) -> Vec<<B as Backend>::Device>
Return all the devices found in the underneath module tree without duplicates.
§fn save_file<FR, PB>(
self,
file_path: PB,
recorder: &FR,
) -> Result<(), RecorderError>
fn save_file<FR, PB>( self, file_path: PB, recorder: &FR, ) -> Result<(), RecorderError>
Save the module to a file using the provided file recorder. Read more
§fn load_file<FR, PB>(
self,
file_path: PB,
recorder: &FR,
device: &<B as Backend>::Device,
) -> Result<Self, RecorderError>
fn load_file<FR, PB>( self, file_path: PB, recorder: &FR, device: &<B as Backend>::Device, ) -> Result<Self, RecorderError>
Load the module from a file using the provided file recorder. Read more
§fn quantize_weights(self, quantizer: &mut Quantizer) -> Self
fn quantize_weights(self, quantizer: &mut Quantizer) -> Self
Quantize the weights of the module.
§impl<B> ModuleDisplay for Normalization<B>where
B: Backend,
impl<B> ModuleDisplay for Normalization<B>where
B: Backend,
§fn format(&self, passed_settings: DisplaySettings) -> String
fn format(&self, passed_settings: DisplaySettings) -> String
Formats the module with provided display settings. Read more
§fn custom_settings(&self) -> Option<DisplaySettings>
fn custom_settings(&self) -> Option<DisplaySettings>
Custom display settings for the module. Read more
§impl<B> ModuleDisplayDefault for Normalization<B>where
B: Backend,
impl<B> ModuleDisplayDefault for Normalization<B>where
B: Backend,
Auto Trait Implementations§
impl<B> !Freeze for Normalization<B>
impl<B> !RefUnwindSafe for Normalization<B>
impl<B> Send for Normalization<B>
impl<B> !Sync for Normalization<B>
impl<B> Unpin for Normalization<B>where
<B as Backend>::FloatTensorPrimitive: Unpin,
<B as Backend>::QuantizedTensorPrimitive: Unpin,
<B as Backend>::Device: Unpin,
impl<B> !UnwindSafe for Normalization<B>
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§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
Fallible version of [
ToCompactString::to_compact_string()] Read more§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
Converts the given value to a [
CompactString]. Read more