Struct dfdx::nn::Dropout

source · []
pub struct Dropout {
    pub p: f32,
    /* private fields */
}
Expand description

A Module that calls dropout() in Module::forward() with probability self.p.

This also implements [Module<(Tensor, Rng)>] if you want to pass in an Rng externally, though this may be harder to use and infect other modules.

Default is implemented as p=0.5 and seeds.

Implementation details: This stores the Rng in a RefCell to maintain compatibility with forward taking a non-mutable reference to self.

Example:

type MlpWithDropout = (
    Dropout,
    Linear<5, 10>,
    ReLU,
    Dropout,
);

// or
let my_mlp = (
    Dropout::p(0.5),
    Linear::<5, 10>::default(),
    ReLU::default(),
    Dropout::p(0.1),
);

Fields

p: f32

Implementations

Constructs Dropout with p and rng.

Constructs Dropout with p and a different seed every call.

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

Sets self.p to 0.5, and seeds StdRng with 0.

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

Calls dropout() using input.1.

The type that this unit produces given Input.

Calls dropout() 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.

Should always be Self

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.