pub struct Dropout2d {
pub one_minus_p: f32,
pub training: bool,
}
Expand description
Apply 2D channel-wise dropout during training.
Randomly zero out entire channels independently with probability p
.
This layer expects the channels to be last, i.e. the input shape should be
NWHC
or WHC
where:N
is the batch dimension,H
is the input
image height,W
is the input image width, andC
is the number of
input channels
The remaining channels are scaled by 1 / (1-p)
to
maintain the expected value of each element. Unlike traditional dropout,
which zeros individual entries, this layer zeros entire channels. This is
beneficial for early convolution layers where adjacent pixels are
correlated. In such case, traditional dropout may not effectively
regularize activations. For more details, see [1].
[1]: Thompson, J., Goroshin, R., Jain, A., LeCun, Y. and Bregler C., 2015. Efficient Object Localization Using Convolutional Networks. CVPR 2015.
Fields§
§one_minus_p: f32
1-p
, where p
is the probability of zeroing a channel. p
is default to
Dropout2d::DEFAULT_P
if not specified.
training: bool
Whether the layer is in training mode. Default to Dropout2d::DEFAULT_TRAINING
if not
specified. Default to Dropout2d::DEFAULT_TRAINING
if not specified.
Implementations§
Trait Implementations§
Source§impl Buildable for Dropout2d
impl Buildable for Dropout2d
Source§type Builder = Dropout2dBuilder
type Builder = Dropout2dBuilder
Source§impl Builder<Dropout2d> for Dropout2dBuilder
impl Builder<Dropout2d> for Dropout2dBuilder
Source§impl Module<&Array> for Dropout2d
impl Module<&Array> for Dropout2d
Source§fn training_mode(&mut self, mode: bool)
fn training_mode(&mut self, mode: bool)
Source§impl ModuleParameters for Dropout2d
impl ModuleParameters for Dropout2d
Source§fn freeze_parameters(&mut self, recursive: bool)
fn freeze_parameters(&mut self, recursive: bool)
Source§fn unfreeze_parameters(&mut self, recursive: bool)
fn unfreeze_parameters(&mut self, recursive: bool)
Source§fn parameters(&self) -> ModuleParamRef<'_>
fn parameters(&self) -> ModuleParamRef<'_>
Source§fn parameters_mut(&mut self) -> ModuleParamMut<'_>
fn parameters_mut(&mut self) -> ModuleParamMut<'_>
Source§fn trainable_parameters(&self) -> ModuleParamRef<'_>
fn trainable_parameters(&self) -> ModuleParamRef<'_>
Source§fn all_frozen(&self) -> Option<bool>
fn all_frozen(&self) -> Option<bool>
None
if there are no parameters.Source§fn any_frozen(&self) -> Option<bool>
fn any_frozen(&self) -> Option<bool>
None
if there are no parameters.Source§fn update(&mut self, parameters: ModuleParam)
fn update(&mut self, parameters: ModuleParam)
Source§fn update_flattened(&mut self, flattened_parameters: FlattenedModuleParam)
fn update_flattened(&mut self, flattened_parameters: FlattenedModuleParam)
Auto Trait Implementations§
impl Freeze for Dropout2d
impl RefUnwindSafe for Dropout2d
impl Send for Dropout2d
impl Sync for Dropout2d
impl Unpin for Dropout2d
impl UnwindSafe for Dropout2d
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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>
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 moreSource§impl<T> IntoOption<T> for T
impl<T> IntoOption<T> for T
Source§fn into_option(self) -> Option<T>
fn into_option(self) -> Option<T>
Option
.Source§impl<T> IntoStrideBy for T
impl<T> IntoStrideBy for T
Source§impl<T> ModuleParametersExt for Twhere
T: ModuleParameters,
impl<T> ModuleParametersExt for Twhere
T: ModuleParameters,
Source§impl<T> Parameter for Twhere
T: ModuleParameters,
impl<T> Parameter for Twhere
T: ModuleParameters,
Source§fn is_frozen(&self) -> Option<bool>
fn is_frozen(&self) -> Option<bool>
None
if the parameter is a module that has no
parameters.