Wrapped

Struct Wrapped 

Source
pub struct Wrapped<W: Wrappable> { /* private fields */ }
Expand description

wraps in a burn wrapper

Implementations§

Source§

impl<A: AutodiffBackend<InnerBackend = B>, B: Backend, W, Y: 'static + ItemLazy + Send + Sync, Z: 'static + ItemLazy + Send + Sync> Wrapped<W>
where <Self as AutodiffModule<A>>::InnerModule: ValidStep<(Value<B>, Value<B>), Z>, Self: TrainStep<(Value<A>, Value<A>), Y>, W::Decomposition: AutodiffModule<A>, W::With<B>: Decompose<Decomposition = <W::Decomposition as AutodiffModule<A>>::InnerModule> + Op<Output = Z>, W: Op<Output = Y> + 'static + Wrappable<B = A>, Y::ItemSync: Adaptor<LossInput<NdArray>>, Z::ItemSync: Adaptor<LossInput<NdArray>>,

Source

pub fn train<I: 'static + Clone + Debug + Into<(Value<A>, Value<A>)> + Send + Sync, J: 'static + Clone + Debug + Into<(Value<B>, Value<B>)> + Send + Sync, O: 'static + Optimizer<Self, A>, S: 'static + LrScheduler, T: 'static + Dataset<I>, V: 'static + Dataset<J>>( self, config: &TrainConfig, optimizer: O, scheduler: S, train: T, valid: V, ) -> Wrapped<W::With<B>>
where O::Record: 'static, S::Record<A>: 'static,

trains the model

Source§

impl<W: Wrappable> Wrapped<W>

Source

pub fn inner(&self) -> &W

references the inner value

Source

pub fn inner_mut(&mut self) -> &mut W

references the inner value

Source

pub fn into_inner(self) -> W

unwraps the inner value

Source

pub fn new(inner: W) -> Self

creates a new wrapped value

Trait Implementations§

Source§

impl<W: AI<X, Y> + Wrappable, X, Y> AI<X, Y> for Wrapped<W>

Source§

fn forward(&self, input: X) -> Y

applies to the input
Source§

fn forward_mut(&mut self, input: X) -> Y

applies to the input, possibly updating internal caches
Source§

impl<A: AutodiffBackend, W: Wrappable<B = A>> AutodiffModule<A> for Wrapped<W>

Source§

type InnerModule = Wrapped<<W as Wrappable>::With<<A as AutodiffBackend>::InnerBackend>>

Inner module without auto-differentiation.
Source§

fn valid(&self) -> Self::InnerModule

Get the same module, but on the inner backend without auto-differentiation.
Source§

impl<W: Clone + Wrappable> Clone for Wrapped<W>

Source§

fn clone(&self) -> Wrapped<W>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<W: Debug + Wrappable> Debug for Wrapped<W>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<W: Wrappable> Decompose for Wrapped<W>

Source§

type Decomposition = <W as Decompose>::Decomposition

the decomposed type
Source§

fn compose(decomposition: Self::Decomposition) -> Self

recreates from the decomposition
Source§

fn decompose(self) -> Self::Decomposition

owned decomposition
Source§

fn decompose_cloned(&self) -> Self::Decomposition

decomposition that copies data
Source§

impl<W: Default + Wrappable> Default for Wrapped<W>

Source§

fn default() -> Wrapped<W>

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

impl<W: Wrappable> Display for Wrapped<W>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<W: Wrappable> From<W> for Wrapped<W>

Source§

fn from(value: W) -> Self

Converts to this type from the input type.
Source§

impl<B: Backend, W: Wrappable<B = B>> Module<B> for Wrapped<W>
where W::Decomposition: Module<B>,

Source§

type Record = <<W as Decompose>::Decomposition as Module<B>>::Record

Type to save and load the module.
Source§

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

fn devices(&self) -> Vec<<B as Backend>::Device>

Return all the devices found in the underneath module tree without duplicates.
Source§

fn fork(self, device: &<B as Backend>::Device) -> Self

Fork the module and all of its sub-modules to the given device. Read more
Source§

fn into_record(self) -> Self::Record

Convert the module into a record containing the state.
Source§

fn load_file<F: FileRecorder<B>, P: Into<PathBuf>>( self, filepath: P, recorder: &F, device: &<B as Backend>::Device, ) -> Result<Self, RecorderError>

Load the module from a file using the provided file recorder. Read more
Source§

fn load_record(self, record: Self::Record) -> Self

Load the module state from a record.
Source§

fn map<Mapper: ModuleMapper<B>>(self, mapper: &mut Mapper) -> Self

Map each tensor parameter in the module with a mapper.
Source§

fn num_params(&self) -> usize

Get the number of parameters the module has, including all of its sub-modules.
Source§

fn quantize_weights(self, quantizer: &mut Quantizer) -> Self

Quantize the weights of the module.
Source§

fn save_file<F: FileRecorder<B>, P: Into<PathBuf>>( self, filepath: P, recorder: &F, ) -> Result<(), RecorderError>

Save the module to a file using the provided file recorder. Read more
Source§

fn to_device(self, device: &<B as Backend>::Device) -> Self

Move the module and all of its sub-modules to the given device. Read more
Source§

fn visit<Visitor: ModuleVisitor<B>>(&self, visitor: &mut Visitor)

Visit each tensor parameter in the module with a visitor.
Source§

fn no_grad(self) -> Self

Each tensor in the module tree will not require grad. Read more
Source§

impl<W: Wrappable> ModuleDisplay for Wrapped<W>

Source§

fn custom_content(&self, content: Content) -> Option<Content>

Custom attributes for the module. Read more
Source§

fn custom_settings(&self) -> Option<DisplaySettings>

Custom display settings for the module. Read more
Source§

fn format(&self, passed_settings: DisplaySettings) -> String

Formats the module with provided display settings. Read more
Source§

impl<W: Wrappable> ModuleDisplayDefault for Wrapped<W>

Source§

fn content(&self, content: Content) -> Option<Content>

Attributes of the module used for display purposes. Read more
Source§

fn num_params(&self) -> usize

Gets the number of the parameters of the module.
Source§

impl<W: Op + Wrappable> Op for Wrapped<W>

Source§

type Output = <W as Op>::Output

suggested output type to help with composition coherence. Ideally, Self should implement AI<X,Self::Output> for some X
Source§

fn abnormal_softmax(self, temperature: f32) -> AbnormalSoftmax<Self>
where Self: Sized, AbnormalSoftmax<Self>: Op,

wraps with a softmax operation
Source§

fn abs(self) -> Abs<Self>
where Self: Sized, Abs<Self>: Op,

wraps with an absolute value operation
Source§

fn acc_q(self, gamma: f32) -> AccQ<Self>
where AccQ<Self>: Op, Self: Sized,

wraps with a accq operation
Source§

fn cat(self, dim: i32) -> Cat<Self>
where Cat<Self>: Op, Self: Sized,

wraps with a cat operation
Source§

fn chain<B>(self, b: B) -> Sequential<(Self, B)>
where Self: Sized, Sequential<(Self, B)>: Op,

sequences with another ai operation
Source§

fn cross_entropy(self, temperature: f32) -> CrossEntropy<Self>
where CrossEntropy<Self>: Op, Self: Sized,

wraps with a cross entropy operation. If temperature is a number it will be used to apply softmax to the logits before computing entropy with the target. if the input will already be a probability distribution instead of logits, put NaN temperature
Source§

fn duplicate(self) -> Duplicate<Self>
where Duplicate<Self>: Op, Self: Sized,

wraps with a duplicate operation
Source§

fn fix_type<Z>(self) -> SetType<Self, Z, Z>
where Self: AI<Z, Z> + Sized,

set type but with the same input and output
Source§

fn flatten<R: Clone>(self, args: R) -> Flatten<Self, R>
where Flatten<Self, R>: Op, Self: Sized,

wraps with a flatten layer
Source§

fn forward_fixed<Z>(&self, input: Z) -> Z
where Self: AI<Z, Z> + Sized,

applies to the input
Source§

fn forward_fixed_mut<Z>(&mut self, input: Z) -> Z
where Self: AI<Z, Z> + Sized,

applies to the input
Source§

fn forward_typed<W, Z>(&self, input: W) -> Z
where Self: AI<W, Z> + Sized,

applies to the input
Source§

fn forward_typed_mut<W, Z>(&mut self, input: W) -> Z
where Self: AI<W, Z> + Sized,

applies to the input, possibly updating internal caches
Source§

fn infer_autoregressive<X, Y>(self, input: X) -> Autoregression<Self, Y>
where Self: AI<X, Y> + AI<Y, Y> + Sized, Y: Clone,

creates an autoregressive inference
Source§

fn log_softmax(self, temperature: f32) -> LogSoftmax<Self>
where Self: Sized, LogSoftmax<Self>: Op,

wraps with a softmax operation
Source§

fn map<B>(self, b: B) -> Map<Sequential<(Self, B)>>
where Map<Sequential<(Self, B)>>: Op, Self: Sized, Sequential<(Self, B)>: Op,

applies the operation to every output
Source§

fn mean(self) -> Mean<Self>
where Mean<Self>: Op, Self: Sized,

wraps with a mean operation
Source§

fn optional(self) -> Option<Self>
where Self: Sized,

creates an optional operation
Source§

fn reshape<R: Clone>(self, args: R) -> Reshape<Self, R>
where Reshape<Self, R>: Op, Self: Sized,

wraps with a reshape layer
Source§

fn residual(self) -> Residual<Self>
where Residual<Self>: Op, Self: Sized,

wraps in a residual layer
Source§

fn set_type<W, Z>(self) -> SetType<Self, W, Z>
where Self: AI<W, Z> + Sized,

sets the input output types
Source§

fn soft_choose(self, temperature: f32) -> Choose<Self>
where Self: Sized, Choose<Self>: Op,

wraps with a choose operation
Source§

fn softmax(self, temperature: f32) -> Softmax<Self>
where Self: Sized, Softmax<Self>: Op,

wraps with a softmax operation
Source§

fn squared_error(self) -> SquaredError<Self>
where SquaredError<Self>: Op, Self: Sized,

wraps with a mse operation
Source§

fn squeeze(self, dim: i32) -> Squeeze<Self>
where Squeeze<Self>: Op, Self: Sized,

wraps with a squeeze operation
Source§

fn stack(self, dim: i32) -> Stack<Self>
where Stack<Self>: Op, Self: Sized,

wraps with a stack operation
Source§

fn to_each(self) -> Map<Self>
where Map<Self>: Op, Self: Sized,

wraps with a map operation
Source§

fn unsqueeze(self, dim: i32) -> Unsqueeze<Self>
where Unsqueeze<Self>: Op, Self: Sized,

wraps with a unsqueeze operation
Source§

fn sum(self) -> Sum<Self>
where Sum<Self>: Op, Self: Sized,

wraps with a sum operation
Source§

fn wrap_inner(self) -> Inner<Self>
where Self: Sized,

wraps the inner value so it can be unwrapped with unwrap inner
Source§

fn zip<B>(self, b: B) -> Zip<(Self, B)>
where Self: Sized, Zip<(Self, B)>: Op,

zips with another ai operation
Source§

impl<C: Backend, W: ToBackend<C, OnBackend = W::With<C>> + Wrappable> ToBackend<C> for Wrapped<W>

Source§

type OnBackend = Wrapped<<W as Wrappable>::With<C>>

the type on the new backend
Source§

fn to_backend_device(self, device: &C::Device) -> Self::OnBackend

moves the module to the backend with the device
Source§

fn to_backend(self) -> Self::OnBackend

moves the module to the backend with the device
Source§

impl<A: AutodiffBackend, W: AI<X, LossOutput<A>> + Wrappable<B = A>, X> TrainStep<X, ClassificationOutput<A>> for Wrapped<Classification<W>>

Source§

fn step(&self, item: X) -> TrainOutput<ClassificationOutput<A>>

Runs the training step, which executes the forward and backward passes. Read more
Source§

fn optimize<B, O>(self, optim: &mut O, lr: f64, grads: GradientsParams) -> Self
where B: AutodiffBackend, O: Optimizer<Self, B>, Self: AutodiffModule<B>,

Optimize the current module with the provided gradients and learning rate. Read more
Source§

impl<A: AutodiffBackend, W: AI<X, LossOutput<A>> + Wrappable<B = A>, X> TrainStep<X, RegressionOutput<A>> for Wrapped<Regression<W>>

Source§

fn step(&self, item: X) -> TrainOutput<RegressionOutput<A>>

Runs the training step, which executes the forward and backward passes. Read more
Source§

fn optimize<B, O>(self, optim: &mut O, lr: f64, grads: GradientsParams) -> Self
where B: AutodiffBackend, O: Optimizer<Self, B>, Self: AutodiffModule<B>,

Optimize the current module with the provided gradients and learning rate. Read more
Source§

impl<W: UnwrapInner + Wrappable> UnwrapInner for Wrapped<W>

Source§

type Inner = <W as UnwrapInner>::Inner

the inner type
Source§

fn unwrap_inner(self) -> Self::Inner

unwraps the inner value
Source§

impl<B: Backend, W: AI<X, LossOutput<B>> + Wrappable<B = B>, X> ValidStep<X, ClassificationOutput<B>> for Wrapped<Classification<W>>
where W::Decomposition: Module<B>,

Source§

fn step(&self, item: X) -> ClassificationOutput<B>

Runs a validation step. Read more
Source§

impl<B: Backend, W: AI<X, LossOutput<B>> + Wrappable<B = B>, X> ValidStep<X, RegressionOutput<B>> for Wrapped<Regression<W>>
where W::Decomposition: Module<B>,

Source§

fn step(&self, item: X) -> RegressionOutput<B>

Runs a validation step. Read more
Source§

impl<W: Copy + Wrappable> Copy for Wrapped<W>

Auto Trait Implementations§

§

impl<W> Freeze for Wrapped<W>
where W: Freeze,

§

impl<W> RefUnwindSafe for Wrapped<W>
where W: RefUnwindSafe,

§

impl<W> Send for Wrapped<W>

§

impl<W> Sync for Wrapped<W>
where W: Sync,

§

impl<W> Unpin for Wrapped<W>
where W: Unpin,

§

impl<W> UnwindSafe for Wrapped<W>
where W: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Adaptor<()> for T

Source§

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

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

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

Initializes a with the given initializer. Read more
Source§

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

Dereferences the given pointer. Read more
Source§

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

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

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

impl<T> Shortcuts for T
where T: Op + ?Sized,

Source§

fn classification(self) -> Classification<Self>
where Classification<Self>: Op, Self: Sized,

wraps in a classification wrapper
Source§

fn regression(self) -> Regression<Self>
where Regression<Self>: Op, Self: Sized,

wraps in a regression wrapper
Source§

fn wrap(self) -> Wrapped<Self>
where Self: Wrappable,

wraps in a burn wrapper
Source§

impl<T> ToCompactString for T
where T: Display,

Source§

impl<T> ToLine for T
where T: Display,

Source§

fn to_line(&self) -> Line<'_>

Converts the value to a Line.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToSpan for T
where T: Display,

Source§

fn to_span(&self) -> Span<'_>

Converts the value to a Span.
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T> ToText for T
where T: Display,

Source§

fn to_text(&self) -> Text<'_>

Converts the value to a Text.
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.
Source§

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

Source§

fn vzip(self) -> V