Dropout Layers#
Dropout randomly zeros elements during training as a regularization technique, preventing overfitting by forcing the network to learn redundant representations. During evaluation, dropout is disabled and outputs are scaled appropriately.
Dropout: Standard dropout for fully-connected layers
Dropout2d/3d: Spatial dropout that zeros entire channels (better for CNNs)
AlphaDropout: Maintains self-normalizing property (use with SELU activation)
Note
Remember to call model->train() during training and model->eval() during
inference to properly enable/disable dropout behavior.
Dropout#
-
class Dropout : public torch::nn::ModuleHolder<DropoutImpl>#
A
ModuleHoldersubclass forDropoutImpl.See the documentation for
DropoutImplclass to learn what methods it provides, and examples of how to useDropoutwithtorch::nn::DropoutOptions. See the documentation forModuleHolderto learn about PyTorch’s module storage semantics.Public Types
-
using Impl = DropoutImpl#
-
using Impl = DropoutImpl#
-
class DropoutImpl : public torch::nn::detail::_DropoutNd<DropoutImpl>#
Applies dropout over a 1-D input.
See https://pytorch.org/docs/main/nn.html#torch.nn.Dropout to learn about the exact behavior of this module.
See the documentation for
torch::nn::DropoutOptionsclass to learn what constructor arguments are supported for this module.Example:
Dropout model(DropoutOptions().p(0.42).inplace(true));
Example:
auto dropout = torch::nn::Dropout(torch::nn::DropoutOptions(0.5));
Dropout2d / Dropout3d#
-
class Dropout2d : public torch::nn::ModuleHolder<Dropout2dImpl>#
A
ModuleHoldersubclass forDropout2dImpl.See the documentation for
Dropout2dImplclass to learn what methods it provides, and examples of how to useDropout2dwithtorch::nn::Dropout2dOptions. See the documentation forModuleHolderto learn about PyTorch’s module storage semantics.Public Types
-
using Impl = Dropout2dImpl#
-
using Impl = Dropout2dImpl#
-
class Dropout2dImpl : public torch::nn::detail::_DropoutNd<Dropout2dImpl>#
Applies dropout over a 2-D input.
See https://pytorch.org/docs/main/nn.html#torch.nn.Dropout2d to learn about the exact behavior of this module.
See the documentation for
torch::nn::Dropout2dOptionsclass to learn what constructor arguments are supported for this module.Example:
Dropout2d model(Dropout2dOptions().p(0.42).inplace(true));
-
class Dropout3d : public torch::nn::ModuleHolder<Dropout3dImpl>#
A
ModuleHoldersubclass forDropout3dImpl.See the documentation for
Dropout3dImplclass to learn what methods it provides, and examples of how to useDropout3dwithtorch::nn::Dropout3dOptions. See the documentation forModuleHolderto learn about PyTorch’s module storage semantics.Public Types
-
using Impl = Dropout3dImpl#
-
using Impl = Dropout3dImpl#
-
class Dropout3dImpl : public torch::nn::detail::_DropoutNd<Dropout3dImpl>#
Applies dropout over a 3-D input.
See https://pytorch.org/docs/main/nn.html#torch.nn.Dropout3d to learn about the exact behavior of this module.
See the documentation for
torch::nn::Dropout3dOptionsclass to learn what constructor arguments are supported for this module.Example:
Dropout3d model(Dropout3dOptions().p(0.42).inplace(true));
AlphaDropout#
-
class AlphaDropout : public torch::nn::ModuleHolder<AlphaDropoutImpl>#
A
ModuleHoldersubclass forAlphaDropoutImpl.See the documentation for
AlphaDropoutImplclass to learn what methods it provides, and examples of how to useAlphaDropoutwithtorch::nn::AlphaDropoutOptions. See the documentation forModuleHolderto learn about PyTorch’s module storage semantics.Public Types
-
using Impl = AlphaDropoutImpl#
-
using Impl = AlphaDropoutImpl#
-
class AlphaDropoutImpl : public torch::nn::detail::_DropoutNd<AlphaDropoutImpl>#
Applies Alpha Dropout over the input.
See https://pytorch.org/docs/main/nn.html#torch.nn.AlphaDropout to learn about the exact behavior of this module.
See the documentation for
torch::nn::AlphaDropoutOptionsclass to learn what constructor arguments are supported for this module.Example:
AlphaDropout model(AlphaDropoutOptions(0.2).inplace(true));
Public Functions
-
virtual void pretty_print(std::ostream &stream) const override#
Pretty prints the
AlphaDropoutmodule into the givenstream.
-
virtual void pretty_print(std::ostream &stream) const override#
FeatureAlphaDropout#
-
class FeatureAlphaDropout : public torch::nn::ModuleHolder<FeatureAlphaDropoutImpl>#
A
ModuleHoldersubclass forFeatureAlphaDropoutImpl.See the documentation for
FeatureAlphaDropoutImplclass to learn what methods it provides, and examples of how to useFeatureAlphaDropoutwithtorch::nn::FeatureAlphaDropoutOptions. See the documentation forModuleHolderto learn about PyTorch’s module storage semantics.Public Types
-
using Impl = FeatureAlphaDropoutImpl#
-
using Impl = FeatureAlphaDropoutImpl#
-
class FeatureAlphaDropoutImpl : public torch::nn::detail::_DropoutNd<FeatureAlphaDropoutImpl>#
See the documentation for
torch::nn::FeatureAlphaDropoutOptionsclass to learn what constructor arguments are supported for this module.Example:
FeatureAlphaDropout model(FeatureAlphaDropoutOptions(0.2).inplace(true));
Public Functions
-
virtual void pretty_print(std::ostream &stream) const override#
Pretty prints the
FeatureAlphaDropoutmodule into the givenstream.
-
virtual void pretty_print(std::ostream &stream) const override#