pub struct Dropout { /* private fields */ }Expand description
Dropout regularization layer.
During training, randomly zeroes elements with probability p.
During evaluation, returns input unchanged.
The output is scaled by 1/(1-p) during training to maintain
expected values (inverted dropout).
§Example
ⓘ
use aprender::nn::{Module, Dropout};
use aprender::autograd::Tensor;
let mut dropout = Dropout::new(0.5);
let x = Tensor::ones(&[10, 10]);
dropout.train();
let y_train = dropout.forward(&x); // ~50% zeros, rest scaled by 2
dropout.eval();
let y_eval = dropout.forward(&x); // same as inputImplementations§
Trait Implementations§
Source§impl Module for Dropout
impl Module for Dropout
Source§fn forward(&self, input: &Tensor) -> Tensor
fn forward(&self, input: &Tensor) -> Tensor
Forward pass with dropout.
§Panics
Panics if the RNG mutex is poisoned (indicates prior thread panic - unrecoverable). This is acceptable per Toyota Way: mutex poisoning means the system is already in a catastrophic state from a prior panic.
Source§fn parameters_mut(&mut self) -> Vec<&mut Tensor>
fn parameters_mut(&mut self) -> Vec<&mut Tensor>
Get mutable references to all learnable parameters. Read more
Source§fn refresh_caches(&mut self)
fn refresh_caches(&mut self)
Refresh any cached computations after parameters have been modified. Read more
Source§fn num_parameters(&self) -> usize
fn num_parameters(&self) -> usize
Get the number of learnable parameters.
Auto Trait Implementations§
impl !Freeze for Dropout
impl RefUnwindSafe for Dropout
impl Send for Dropout
impl Sync for Dropout
impl Unpin for Dropout
impl UnsafeUnpin for Dropout
impl UnwindSafe for Dropout
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
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 more