pub struct Dropout {
pub p: f32,
/* private fields */
}
Expand description
Does nothing as a Module, and calls dropout() as ModuleMut with probability 1.0 / N
.
To prevent programmer error, Module and ModuleMut are only implemented for specific tapes:
- Module requires that the input tensor has a NoneTape. i.e. that gradients are not being tracked.
- ModuleMut requires that the tensor has a OwnedTape. i.e. that the gradients are being tracked
That means the following will fail to compile:
ⓘ
let dropout: Dropout = Default::default();
let x: Tensor1D<5, OwnedTape> = Tensor1D::zeros().trace();
dropout.forward(x);
ⓘ
let mut dropout: Dropout = Default::default();
let x: Tensor1D<5, NoneTape> = TensorCreator::zeros();
dropout.forward_mut(x);
Generics:
N
: p is set as1.0 / N
Examples:
let mut dropout = Dropout::new(0.5, 0);
let t: Tensor2D<2, 5> = Tensor2D::ones();
let r = dropout.forward_mut(t.trace());
assert_eq!(r.data(), &[[2.0, 2.0, 2.0, 0.0, 0.0], [2.0, 2.0, 0.0, 0.0, 2.0]]);
Fields
p: f32
Implementations
Trait Implementations
sourceimpl CanUpdateWithGradients for Dropout
impl CanUpdateWithGradients for Dropout
sourcefn update<G: GradientProvider>(&mut self, _: &mut G, _: &mut UnusedTensors)
fn update<G: GradientProvider>(&mut self, _: &mut G, _: &mut UnusedTensors)
Does nothing.
sourceimpl LoadFromNpz for Dropout
impl LoadFromNpz for Dropout
sourceimpl<T: Tensor<Dtype = f32, Tape = OwnedTape>> ModuleMut<T> for Dropout
impl<T: Tensor<Dtype = f32, Tape = OwnedTape>> ModuleMut<T> for Dropout
sourcefn forward_mut(&mut self, input: T) -> Self::Output
fn forward_mut(&mut self, input: T) -> Self::Output
Calls dropout()
type Output = T
type Output = T
The type that this unit produces given
Input
.sourceimpl ResetParams for Dropout
impl ResetParams for Dropout
sourcefn reset_params<R: Rng>(&mut self, _: &mut R)
fn reset_params<R: Rng>(&mut self, _: &mut R)
Does nothing.
Auto Trait Implementations
impl RefUnwindSafe for Dropout
impl Send for Dropout
impl Sync for Dropout
impl Unpin for Dropout
impl UnwindSafe for Dropout
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more