Struct dfdx::nn::DropoutOneIn
source · [−]pub struct DropoutOneIn<const N: usize> { /* 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: DropoutOneIn<2> = Default::default();
let x: Tensor1D<5, OwnedTape> = Tensor1D::zeros().trace();
dropout.forward(x);
ⓘ
let mut dropout: DropoutOneIn<2> = 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: DropoutOneIn<2> = Default::default();
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]]);
Trait Implementations
sourceimpl<const N: usize> CanUpdateWithGradients for DropoutOneIn<N>
impl<const N: usize> CanUpdateWithGradients for DropoutOneIn<N>
sourcefn update<G: GradientProvider>(&mut self, _: &mut G, _: &mut UnusedTensors)
fn update<G: GradientProvider>(&mut self, _: &mut G, _: &mut UnusedTensors)
Does nothing.
sourceimpl<const N: usize> Clone for DropoutOneIn<N>
impl<const N: usize> Clone for DropoutOneIn<N>
sourcefn clone(&self) -> DropoutOneIn<N>
fn clone(&self) -> DropoutOneIn<N>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresourceimpl<const N: usize> Debug for DropoutOneIn<N>
impl<const N: usize> Debug for DropoutOneIn<N>
sourceimpl<const N: usize> Default for DropoutOneIn<N>
impl<const N: usize> Default for DropoutOneIn<N>
sourceimpl<const N: usize> LoadFromNpz for DropoutOneIn<N>
impl<const N: usize> LoadFromNpz for DropoutOneIn<N>
sourceimpl<const N: usize, T: Tensor<Dtype = f32, Tape = OwnedTape>> ModuleMut<T> for DropoutOneIn<N>
impl<const N: usize, T: Tensor<Dtype = f32, Tape = OwnedTape>> ModuleMut<T> for DropoutOneIn<N>
sourcefn forward_mut(&mut self, input: T) -> Self::Output
fn forward_mut(&mut self, input: T) -> Self::Output
Calls dropout() with p=1/N
using self.rng
.
type Output = T
type Output = T
The type that this unit produces given
Input
.sourceimpl<const N: usize> ResetParams for DropoutOneIn<N>
impl<const N: usize> ResetParams for DropoutOneIn<N>
sourcefn reset_params<R: Rng>(&mut self, _: &mut R)
fn reset_params<R: Rng>(&mut self, _: &mut R)
Does nothing.
Auto Trait Implementations
impl<const N: usize> RefUnwindSafe for DropoutOneIn<N>
impl<const N: usize> Send for DropoutOneIn<N>
impl<const N: usize> Sync for DropoutOneIn<N>
impl<const N: usize> Unpin for DropoutOneIn<N>
impl<const N: usize> UnwindSafe for DropoutOneIn<N>
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