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:

  1. Module requires that the input tensor has a NoneTape. i.e. that gradients are not being tracked.
  2. ModuleMut requires that the tensor has a OwnedTape. i.e. that the gradients are being tracked

That means the following will fail to compile:

  1. Using Module with OwnedTape fails to compile
let dropout: DropoutOneIn<2> = Default::default();
let x: Tensor1D<5, OwnedTape> = Tensor1D::zeros().trace();
dropout.forward(x);
  1. Using ModuleMut with NoneTape fails to compile
let mut dropout: DropoutOneIn<2> = Default::default();
let x: Tensor1D<5, NoneTape> = TensorCreator::zeros();
dropout.forward_mut(x);

Generics:

  • N: p is set as 1.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

Does nothing.

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more

Seeds StdRng with a new seed every time this is called. The seed is initialized with a deterministic value.

Loads data from a .npz zip archive at the specified path. Read more
Reads this object from a ZipArchive. r with a base filename of filename_prefix. Read more

Does nothing

The type that this unit produces given Input.

Calls dropout() with p=1/N using self.rng.

The type that this unit produces given Input.

Does nothing.

Save this object into the .npz file determined located at path. Read more
Write this object into ZipWriter w with a base filename of filename_prefix. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.