pub struct Dropout<F>{ /* private fields */ }Expand description
Dropout layer
During training, randomly sets input elements to zero with probability p.
During inference, scales the output by 1/(1-p) to maintain the expected value.
Implementations§
Source§impl<F> Dropout<F>
impl<F> Dropout<F>
Sourcepub fn new<R>(p: f64, rng: &mut R) -> Result<Dropout<F>, NeuralError>
pub fn new<R>(p: f64, rng: &mut R) -> Result<Dropout<F>, NeuralError>
Create a new dropout layer
§Arguments
p- Dropout probability (0.0 to 1.0)rng- Random number generator
Sourcepub fn set_training(&mut self, training: bool)
pub fn set_training(&mut self, training: bool)
Set the training mode In training mode, elements are randomly dropped. In inference mode, all elements are kept but scaled.
Sourcepub fn is_training(&self) -> bool
pub fn is_training(&self) -> bool
Get the training mode
Trait Implementations§
Source§impl<F> Layer<F> for Dropout<F>
impl<F> Layer<F> for Dropout<F>
Source§fn forward(
&self,
input: &ArrayBase<OwnedRepr<F>, Dim<IxDynImpl>>,
) -> Result<ArrayBase<OwnedRepr<F>, Dim<IxDynImpl>>, NeuralError>
fn forward( &self, input: &ArrayBase<OwnedRepr<F>, Dim<IxDynImpl>>, ) -> Result<ArrayBase<OwnedRepr<F>, Dim<IxDynImpl>>, NeuralError>
Forward pass of the layer Read more
Source§fn backward(
&self,
_input: &ArrayBase<OwnedRepr<F>, Dim<IxDynImpl>>,
grad_output: &ArrayBase<OwnedRepr<F>, Dim<IxDynImpl>>,
) -> Result<ArrayBase<OwnedRepr<F>, Dim<IxDynImpl>>, NeuralError>
fn backward( &self, _input: &ArrayBase<OwnedRepr<F>, Dim<IxDynImpl>>, grad_output: &ArrayBase<OwnedRepr<F>, Dim<IxDynImpl>>, ) -> Result<ArrayBase<OwnedRepr<F>, Dim<IxDynImpl>>, NeuralError>
Backward pass of the layer to compute gradients Read more
Source§fn update(&mut self, _learningrate: F) -> Result<(), NeuralError>
fn update(&mut self, _learningrate: F) -> Result<(), NeuralError>
Update the layer parameters with the given learning rate
Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Get the layer as a mutable dyn Any for downcasting
Source§fn set_training(&mut self, training: bool)
fn set_training(&mut self, training: bool)
Set the layer to training mode (true) or evaluation mode (false)
Source§fn is_training(&self) -> bool
fn is_training(&self) -> bool
Get the current training mode
Source§fn layer_type(&self) -> &str
fn layer_type(&self) -> &str
Get the type of the layer (e.g., “Dense”, “Conv2D”)
Source§fn parameter_count(&self) -> usize
fn parameter_count(&self) -> usize
Get the number of trainable parameters in this layer
Source§fn layer_description(&self) -> String
fn layer_description(&self) -> String
Get a detailed description of this layer
Source§fn params(&self) -> Vec<ArrayBase<OwnedRepr<F>, Dim<IxDynImpl>>>
fn params(&self) -> Vec<ArrayBase<OwnedRepr<F>, Dim<IxDynImpl>>>
Get the parameters of the layer
Source§fn gradients(&self) -> Vec<ArrayBase<OwnedRepr<F>, Dim<IxDynImpl>>>
fn gradients(&self) -> Vec<ArrayBase<OwnedRepr<F>, Dim<IxDynImpl>>>
Get the gradients of the layer parameters
Source§fn set_gradients(
&mut self,
_gradients: &[ArrayBase<OwnedRepr<F>, Dim<IxDynImpl>>],
) -> Result<(), NeuralError>
fn set_gradients( &mut self, _gradients: &[ArrayBase<OwnedRepr<F>, Dim<IxDynImpl>>], ) -> Result<(), NeuralError>
Set the gradients of the layer parameters
Source§fn set_params(
&mut self,
_params: &[ArrayBase<OwnedRepr<F>, Dim<IxDynImpl>>],
) -> Result<(), NeuralError>
fn set_params( &mut self, _params: &[ArrayBase<OwnedRepr<F>, Dim<IxDynImpl>>], ) -> Result<(), NeuralError>
Set the parameters of the layer
impl<F> Send for Dropout<F>
impl<F> Sync for Dropout<F>
Auto Trait Implementations§
impl<F> Freeze for Dropout<F>where
F: Freeze,
impl<F> RefUnwindSafe for Dropout<F>where
F: RefUnwindSafe,
impl<F> Unpin for Dropout<F>where
F: Unpin,
impl<F> UnsafeUnpin for Dropout<F>where
F: UnsafeUnpin,
impl<F> UnwindSafe for Dropout<F>where
F: 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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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.