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>
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
Read this value from the supplied reader. Same as
ReadEndian::read_from_little_endian()
.