Struct Reinitializer

pub struct Reinitializer<B>
where B: Backend,
{ /* private fields */ }
Expand description

Overrides float and int tensors of burn modules.

This is useful for testing.

Implementations§

§

impl<B> Reinitializer<B>
where B: Backend,

pub fn new() -> Reinitializer<B>

Create a new reinitializer.

pub fn apply<M>(self, module: M) -> M
where M: Module<B>,

Apply the reinitialization to the given module.

pub fn constant(self, constant: f64) -> Reinitializer<B>

Set the reinitialization strategy to constant for all tensors.

pub fn constant_float(self, constant: f64) -> Reinitializer<B>

Set the reinitialization strategy to constant for float tensors.

pub fn constant_int(self, constant: i64) -> Reinitializer<B>

Set the reinitialization strategy to constant for int tensors.

pub fn random(self, seed: u64, min: f64, max: f64) -> Reinitializer<B>

Set the reinitialization strategy to random for all tensors.

pub fn random_float(self, seed: u64, min: f64, max: f64) -> Reinitializer<B>

Set the reinitialization strategy to random for float tensors.

pub fn random_int(self, seed: u64, min: i64, max: i64) -> Reinitializer<B>

Set the reinitialization strategy to random for int tensors.

pub fn range(self, min: f64, max: f64) -> Reinitializer<B>

Set the reinitialization strategy to range for all tensors.

pub fn range_float(self, min: f64, max: f64) -> Reinitializer<B>

Set the reinitialization strategy to range for float tensors.

pub fn range_int(self, min: i64, max: i64) -> Reinitializer<B>

Set the reinitialization strategy to range for int tensors.

Trait Implementations§

§

impl<B> Debug for Reinitializer<B>
where B: Debug + Backend,

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
§

impl<B> Default for Reinitializer<B>
where B: Backend,

§

fn default() -> Reinitializer<B>

Returns the “default value” for a type. Read more
§

impl<B> ModuleMapper<B> for Reinitializer<B>
where B: Backend,

§

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
§

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
§

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
§

fn enter_module(&mut self, name: &str, container_type: &str)

Called when entering a submodule. Read more
§

fn exit_module(&mut self, name: &str, container_type: &str)

Called when exiting a submodule. Read more

Auto Trait Implementations§

§

impl<B> Freeze for Reinitializer<B>
where <B as Backend>::FloatElem: Freeze, <B as Backend>::IntElem: Freeze,

§

impl<B> RefUnwindSafe for Reinitializer<B>

§

impl<B> Send for Reinitializer<B>

§

impl<B> Sync for Reinitializer<B>

§

impl<B> Unpin for Reinitializer<B>
where <B as Backend>::FloatElem: Unpin, <B as Backend>::IntElem: Unpin,

§

impl<B> UnwindSafe for Reinitializer<B>

Blanket Implementations§

§

impl<T> Adaptor<()> for T

§

fn adapt(&self)

Adapt the type to be passed to a metric.
Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WasmNotSend for T
where T: Send,

§

impl<T> WasmNotSendSync for T
where T: WasmNotSend + WasmNotSync,

§

impl<T> WasmNotSync for T
where T: Sync,