pub struct LayerBase<F, S, D = Ix2>{ /* private fields */ }Implementations§
Source§impl<F, S, A, D> LayerBase<F, S, D>
impl<F, S, A, D> LayerBase<F, S, D>
pub fn new(rho: F, params: ParamsBase<S, D>) -> Self
Sourcepub fn params(&self) -> &ParamsBase<S, D>
pub fn params(&self) -> &ParamsBase<S, D>
returns an immutable reference to the layer’s parameters
Sourcepub fn params_mut(&mut self) -> &mut ParamsBase<S, D>
pub fn params_mut(&mut self) -> &mut ParamsBase<S, D>
returns a mutable reference to the layer’s parameters
Sourcepub fn rho_mut(&mut self) -> &mut F
pub fn rho_mut(&mut self) -> &mut F
returns a mutable reference to the activation function of the layer
Sourcepub fn with_rho<G>(self, rho: G) -> LayerBase<G, S, D>
pub fn with_rho<G>(self, rho: G) -> LayerBase<G, S, D>
consumes the current instance and returns another with the given activation function. This is useful during the creation of the model, when the activation function is not known yet.
pub fn forward<X, Y>(&self, input: &X) -> Result<Y>where
F: Activator<<ParamsBase<S, D> as Forward<X>>::Output, Output = Y>,
ParamsBase<S, D>: Forward<X, Output = Y>,
X: Clone,
Y: Clone,
Methods from Deref<Target = ParamsBase<S, D>>§
Sourcepub fn bias(&self) -> &ArrayBase<S, <D as Dimension>::Smaller>
pub fn bias(&self) -> &ArrayBase<S, <D as Dimension>::Smaller>
returns an immutable reference to the bias
Sourcepub fn bias_mut(&mut self) -> &mut ArrayBase<S, <D as Dimension>::Smaller>
pub fn bias_mut(&mut self) -> &mut ArrayBase<S, <D as Dimension>::Smaller>
returns a mutable reference to the bias
Sourcepub fn weights_mut(&mut self) -> &mut ArrayBase<S, D>
pub fn weights_mut(&mut self) -> &mut ArrayBase<S, D>
returns a mutable reference to the weights
Sourcepub fn assign_bias(
&mut self,
bias: &ArrayBase<S, <D as Dimension>::Smaller>,
) -> &mut ParamsBase<S, D>
pub fn assign_bias( &mut self, bias: &ArrayBase<S, <D as Dimension>::Smaller>, ) -> &mut ParamsBase<S, D>
assign the bias
Sourcepub fn assign_weights(
&mut self,
weights: &ArrayBase<S, D>,
) -> &mut ParamsBase<S, D>
pub fn assign_weights( &mut self, weights: &ArrayBase<S, D>, ) -> &mut ParamsBase<S, D>
assign the weights
Sourcepub fn replace_bias(
&mut self,
bias: ArrayBase<S, <D as Dimension>::Smaller>,
) -> ArrayBase<S, <D as Dimension>::Smaller>
pub fn replace_bias( &mut self, bias: ArrayBase<S, <D as Dimension>::Smaller>, ) -> ArrayBase<S, <D as Dimension>::Smaller>
replace the bias and return the previous state; uses replace
Sourcepub fn replace_weights(&mut self, weights: ArrayBase<S, D>) -> ArrayBase<S, D>
pub fn replace_weights(&mut self, weights: ArrayBase<S, D>) -> ArrayBase<S, D>
replace the weights and return the previous state; uses replace
Sourcepub fn set_bias(
&mut self,
bias: ArrayBase<S, <D as Dimension>::Smaller>,
) -> &mut ParamsBase<S, D>
pub fn set_bias( &mut self, bias: ArrayBase<S, <D as Dimension>::Smaller>, ) -> &mut ParamsBase<S, D>
set the bias
Sourcepub fn set_weights(&mut self, weights: ArrayBase<S, D>) -> &mut ParamsBase<S, D>
pub fn set_weights(&mut self, weights: ArrayBase<S, D>) -> &mut ParamsBase<S, D>
set the weights
Sourcepub fn backward<X, Y, Z>(
&mut self,
input: &X,
grad: &Y,
lr: A,
) -> Result<Z, Error>
pub fn backward<X, Y, Z>( &mut self, input: &X, grad: &Y, lr: A, ) -> Result<Z, Error>
perform a single backpropagation step
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
returns true if both the weights and bias are empty; uses is_empty
Sourcepub fn is_weights_empty(&self) -> bool
pub fn is_weights_empty(&self) -> bool
returns true if the weights are empty
Sourcepub fn is_bias_empty(&self) -> bool
pub fn is_bias_empty(&self) -> bool
returns true if the bias is empty
Sourcepub fn count_weight(&self) -> usize
pub fn count_weight(&self) -> usize
the total number of elements within the weight tensor
Sourcepub fn count_bias(&self) -> usize
pub fn count_bias(&self) -> usize
the total number of elements within the bias tensor
Sourcepub fn shape(&self) -> &[usize]
pub fn shape(&self) -> &[usize]
returns the shape of the parameters; uses the shape of the weight tensor
Sourcepub fn shape_bias(&self) -> &[usize]
pub fn shape_bias(&self) -> &[usize]
returns the shape of the bias tensor; the shape should be equivalent to that of the weight tensor minus the “zero-th” axis
Sourcepub fn to_owned(&self) -> ParamsBase<OwnedRepr<A>, D>
pub fn to_owned(&self) -> ParamsBase<OwnedRepr<A>, D>
returns an owned instance of the parameters
Sourcepub fn to_shape<Sh>(
&self,
shape: Sh,
) -> Result<ParamsBase<CowRepr<'_, A>, <Sh as ShapeBuilder>::Dim>, Error>
pub fn to_shape<Sh>( &self, shape: Sh, ) -> Result<ParamsBase<CowRepr<'_, A>, <Sh as ShapeBuilder>::Dim>, Error>
change the shape of the parameters; the shape of the bias parameters is determined by removing the “zero-th” axis of the given shape
returns a new ParamsBase instance with the same paramaters, but using a shared
representation of the data;
Sourcepub fn view(&self) -> ParamsBase<ViewRepr<&A>, D>where
S: Data,
pub fn view(&self) -> ParamsBase<ViewRepr<&A>, D>where
S: Data,
returns a “view” of the parameters; see view for more information
Sourcepub fn view_mut(&mut self) -> ParamsBase<ViewRepr<&mut A>, D>where
S: DataMut,
pub fn view_mut(&mut self) -> ParamsBase<ViewRepr<&mut A>, D>where
S: DataMut,
returns mutable view of the parameters; see view_mut for more information
Sourcepub fn iter(&self) -> Iter<'_, A, D>where
D: RemoveAxis,
S: Data,
pub fn iter(&self) -> Iter<'_, A, D>where
D: RemoveAxis,
S: Data,
an iterator of the parameters; the created iterator zips together an axis iterator over the columns of the weights and an iterator over the bias
Sourcepub fn iter_mut(&mut self) -> IterMut<'_, A, D>where
D: RemoveAxis,
S: DataMut,
pub fn iter_mut(&mut self) -> IterMut<'_, A, D>where
D: RemoveAxis,
S: DataMut,
returns a mutable iterator of the parameters, IterMut, which essentially zips
together a mutable axis iterator over the columns of the weights against a mutable
iterator over the elements of the bias
Sourcepub fn iter_bias(&self) -> Iter<'_, A, <D as Dimension>::Smaller>where
S: Data,
pub fn iter_bias(&self) -> Iter<'_, A, <D as Dimension>::Smaller>where
S: Data,
returns an iterator over the bias
Sourcepub fn iter_bias_mut(&mut self) -> IterMut<'_, A, <D as Dimension>::Smaller>where
S: DataMut,
pub fn iter_bias_mut(&mut self) -> IterMut<'_, A, <D as Dimension>::Smaller>where
S: DataMut,
returns a mutable iterator over the bias
Sourcepub fn iter_weights(&self) -> Iter<'_, A, D>where
S: Data,
pub fn iter_weights(&self) -> Iter<'_, A, D>where
S: Data,
returns an iterator over the weights
Sourcepub fn iter_weights_mut(&mut self) -> IterMut<'_, A, D>where
S: DataMut,
pub fn iter_weights_mut(&mut self) -> IterMut<'_, A, D>where
S: DataMut,
returns a mutable iterator over the weights; see iter_mut for more
Sourcepub fn apply_gradient<Delta, Z>(
&mut self,
grad: &Delta,
lr: A,
) -> Result<Z, Error>
pub fn apply_gradient<Delta, Z>( &mut self, grad: &Delta, lr: A, ) -> Result<Z, Error>
a convenience method used to apply a gradient to the parameters using the given learning rate.