pub struct FeedForwardNetwork<T: Float + Debug + ScalarOperand + Send + Sync + 'static> { /* private fields */ }Expand description
Feed-forward network implementation
Implementations§
Source§impl<T: Float + Debug + ScalarOperand + Send + Sync + 'static> FeedForwardNetwork<T>
impl<T: Float + Debug + ScalarOperand + Send + Sync + 'static> FeedForwardNetwork<T>
Sourcepub fn new(
input_dimension: usize,
hidden_dimension: usize,
activation: ActivationFunction,
) -> Result<Self>
pub fn new( input_dimension: usize, hidden_dimension: usize, activation: ActivationFunction, ) -> Result<Self>
Create new feed-forward network
Sourcepub fn new_with_dropout(
input_dimension: usize,
hidden_dimension: usize,
activation: ActivationFunction,
dropout_rate: f64,
) -> Result<Self>
pub fn new_with_dropout( input_dimension: usize, hidden_dimension: usize, activation: ActivationFunction, dropout_rate: f64, ) -> Result<Self>
Create with custom dropout rate
Sourcepub fn forward(&mut self, input: &Array2<T>) -> Result<Array2<T>>
pub fn forward(&mut self, input: &Array2<T>) -> Result<Array2<T>>
Forward pass through feed-forward network
Sourcepub fn forward_with_cache(
&mut self,
input: &Array2<T>,
) -> Result<(Array2<T>, FeedForwardCache<T>)>
pub fn forward_with_cache( &mut self, input: &Array2<T>, ) -> Result<(Array2<T>, FeedForwardCache<T>)>
Forward pass that also returns the activations needed for the backward pass. Dropout is bypassed here so that the cached activations match the ones the gradients are computed against.
Sourcepub fn backward(
&mut self,
cache: &FeedForwardCache<T>,
grad_output: &Array2<T>,
learning_rate: T,
) -> Result<Array2<T>>
pub fn backward( &mut self, cache: &FeedForwardCache<T>, grad_output: &Array2<T>, learning_rate: T, ) -> Result<Array2<T>>
Backward pass. Returns dL/d(input) and applies SGD steps to both
linear layers.
Sourcepub fn parameter_count(&self) -> usize
pub fn parameter_count(&self) -> usize
Get parameter count
Sourcepub fn set_training(&mut self, training: bool)
pub fn set_training(&mut self, training: bool)
Set training mode
Sourcepub fn get_activation(&self) -> ActivationFunction
pub fn get_activation(&self) -> ActivationFunction
Get activation function
Sourcepub fn set_activation(&mut self, activation: ActivationFunction)
pub fn set_activation(&mut self, activation: ActivationFunction)
Set activation function
Auto Trait Implementations§
impl<T> Freeze for FeedForwardNetwork<T>where
LinearLayer<T>: Freeze,
impl<T> RefUnwindSafe for FeedForwardNetwork<T>where
LinearLayer<T>: RefUnwindSafe,
impl<T> Send for FeedForwardNetwork<T>where
LinearLayer<T>: Send,
impl<T> Sync for FeedForwardNetwork<T>where
LinearLayer<T>: Sync,
impl<T> Unpin for FeedForwardNetwork<T>where
LinearLayer<T>: Unpin,
impl<T> UnsafeUnpin for FeedForwardNetwork<T>where
LinearLayer<T>: UnsafeUnpin,
impl<T> UnwindSafe for FeedForwardNetwork<T>where
LinearLayer<T>: UnwindSafe,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.