pub struct Reinitializer<B: Backend> { /* private fields */ }Available on crate feature
std only.Expand description
Overrides float and int tensors of burn modules.
This is useful for testing.
Implementations§
Source§impl<B: Backend> Reinitializer<B>
impl<B: Backend> Reinitializer<B>
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new reinitializer.
Sourcepub fn apply<M: Module<B>>(self, module: M) -> M
pub fn apply<M: Module<B>>(self, module: M) -> M
Apply the reinitialization to the given module.
Sourcepub fn constant(self, constant: f64) -> Self
pub fn constant(self, constant: f64) -> Self
Set the reinitialization strategy to constant for all tensors.
Sourcepub fn constant_float(self, constant: f64) -> Self
pub fn constant_float(self, constant: f64) -> Self
Set the reinitialization strategy to constant for float tensors.
Sourcepub fn constant_int(self, constant: i64) -> Self
pub fn constant_int(self, constant: i64) -> Self
Set the reinitialization strategy to constant for int tensors.
Sourcepub fn random(self, seed: u64, min: f64, max: f64) -> Self
pub fn random(self, seed: u64, min: f64, max: f64) -> Self
Set the reinitialization strategy to random for all tensors.
Sourcepub fn random_float(self, seed: u64, min: f64, max: f64) -> Self
pub fn random_float(self, seed: u64, min: f64, max: f64) -> Self
Set the reinitialization strategy to random for float tensors.
Sourcepub fn random_int(self, seed: u64, min: i64, max: i64) -> Self
pub fn random_int(self, seed: u64, min: i64, max: i64) -> Self
Set the reinitialization strategy to random for int tensors.
Sourcepub fn range(self, min: f64, max: f64) -> Self
pub fn range(self, min: f64, max: f64) -> Self
Set the reinitialization strategy to range for all tensors.
Sourcepub fn range_float(self, min: f64, max: f64) -> Self
pub fn range_float(self, min: f64, max: f64) -> Self
Set the reinitialization strategy to range for float tensors.
Trait Implementations§
Source§impl<B: Backend> Default for Reinitializer<B>
impl<B: Backend> Default for Reinitializer<B>
Source§impl<B: Backend> ModuleMapper<B> for Reinitializer<B>
impl<B: Backend> ModuleMapper<B> for Reinitializer<B>
Source§fn map_float<const D: usize>(
&mut self,
param: Param<Tensor<B, D>>,
) -> Param<Tensor<B, D>>
fn map_float<const D: usize>( &mut self, param: Param<Tensor<B, D>>, ) -> Param<Tensor<B, D>>
Map a float parameter in the module. Read more
Source§fn map_int<const D: usize>(
&mut self,
param: Param<Tensor<B, D, Int>>,
) -> Param<Tensor<B, D, Int>>
fn map_int<const D: usize>( &mut self, param: Param<Tensor<B, D, Int>>, ) -> Param<Tensor<B, D, Int>>
Map an int parameter in the module. Read more
Source§fn map_bool<const D: usize>(
&mut self,
param: Param<Tensor<B, D, Bool>>,
) -> Param<Tensor<B, D, Bool>>
fn map_bool<const D: usize>( &mut self, param: Param<Tensor<B, D, Bool>>, ) -> Param<Tensor<B, D, Bool>>
Map a bool parameter in the module. Read more
Auto Trait Implementations§
impl<B> Freeze for Reinitializer<B>
impl<B> RefUnwindSafe for Reinitializer<B>
impl<B> Send for Reinitializer<B>
impl<B> Sync for Reinitializer<B>
impl<B> Unpin for Reinitializer<B>
impl<B> UnwindSafe for Reinitializer<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> 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