Trait Layer

Source
pub trait Layer<S, D>
where D: Dimension, S: RawData<Elem = Self::Scalar>,
{ type Scalar; // Required methods fn params(&self) -> &ParamsBase<S, D>; fn params_mut(&mut self) -> &mut ParamsBase<S, D>; // Provided methods fn set_params(&mut self, params: ParamsBase<S, D>) { ... } fn backward<X, Y, Z, Delta>( &mut self, input: X, error: Y, gamma: Self::Scalar, ) -> Result<Z> where S: Data, Self: ActivateGradient<Y, Delta = Delta>, Self::Scalar: Clone, ParamsBase<S, D>: Backward<X, Delta, Elem = Self::Scalar, Output = Z> { ... } fn forward<X, Y>(&self, input: &X) -> Result<Y> where Y: Tensor<S, D, Scalar = Self::Scalar>, ParamsBase<S, D>: Forward<X, Output = Y>, Self: Activate<Y, Output = Y> { ... } }
Expand description

A layer within a neural-network containing a set of parameters and an activation function. Here, this manifests as a wrapper around the parameters of the layer with a generic activation function and corresponding traits to denote desired behaviors.

Required Associated Types§

Required Methods§

Source

fn params(&self) -> &ParamsBase<S, D>

returns an immutable reference to the parameters of the layer

Source

fn params_mut(&mut self) -> &mut ParamsBase<S, D>

returns a mutable reference to the parameters of the layer

Provided Methods§

Source

fn set_params(&mut self, params: ParamsBase<S, D>)

update the layer parameters

Source

fn backward<X, Y, Z, Delta>( &mut self, input: X, error: Y, gamma: Self::Scalar, ) -> Result<Z>
where S: Data, Self: ActivateGradient<Y, Delta = Delta>, Self::Scalar: Clone, ParamsBase<S, D>: Backward<X, Delta, Elem = Self::Scalar, Output = Z>,

backward propagate error through the layer

Source

fn forward<X, Y>(&self, input: &X) -> Result<Y>
where Y: Tensor<S, D, Scalar = Self::Scalar>, ParamsBase<S, D>: Forward<X, Output = Y>, Self: Activate<Y, Output = Y>,

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<A, F, S, D> Layer<S, D> for LayerBase<F, S, D>
where F: ActivateGradient<A>, D: Dimension, S: RawData<Elem = A>,