Title: Dropout Layers — PyTorch main documentation
Description: Dropout layers in PyTorch C++ — Dropout, Dropout2d, Dropout3d, AlphaDropout, and FeatureAlphaDropout.
Keywords:
Domain: docs.pytorch.org
{
"@context": "https://schema.org",
"@type": "Article",
"name": "Dropout Layers",
"headline": "Dropout Layers",
"description": "Dropout layers in PyTorch C++ \u2014 Dropout, Dropout2d, Dropout3d, AlphaDropout, and FeatureAlphaDropout.",
"url": "/api/nn/dropout.html",
"articleBody": "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-\u003etrain() during training and model-\u003eeval() during inference to properly enable/disable dropout behavior. Dropout# class Dropout : public torch::nn::ModuleHolder\u003cDropoutImpl\u003e# A ModuleHolder subclass for DropoutImpl. See the documentation for DropoutImpl class to learn what methods it provides, and examples of how to use Dropout with torch::nn::DropoutOptions. See the documentation for ModuleHolder to learn about PyTorch\u2019s module storage semantics. Public Types using Impl = DropoutImpl# class DropoutImpl : public torch::nn::detail::_DropoutNd\u003cDropoutImpl\u003e# 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::DropoutOptions class to learn what constructor arguments are supported for this module. Example: Dropout model(DropoutOptions().p(0.42).inplace(true)); Public Functions Tensor forward(Tensor input)# virtual void pretty_print(std::ostream \u0026stream) const override# Pretty prints the Dropout module into the given stream. Example: auto dropout = torch::nn::Dropout(torch::nn::DropoutOptions(0.5)); Dropout2d / Dropout3d# class Dropout2d : public torch::nn::ModuleHolder\u003cDropout2dImpl\u003e# A ModuleHolder subclass for Dropout2dImpl. See the documentation for Dropout2dImpl class to learn what methods it provides, and examples of how to use Dropout2d with torch::nn::Dropout2dOptions. See the documentation for ModuleHolder to learn about PyTorch\u2019s module storage semantics. Public Types using Impl = Dropout2dImpl# class Dropout2dImpl : public torch::nn::detail::_DropoutNd\u003cDropout2dImpl\u003e# 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::Dropout2dOptions class to learn what constructor arguments are supported for this module. Example: Dropout2d model(Dropout2dOptions().p(0.42).inplace(true)); Public Functions Tensor forward(Tensor input)# virtual void pretty_print(std::ostream \u0026stream) const override# Pretty prints the Dropout2d module into the given stream. class Dropout3d : public torch::nn::ModuleHolder\u003cDropout3dImpl\u003e# A ModuleHolder subclass for Dropout3dImpl. See the documentation for Dropout3dImpl class to learn what methods it provides, and examples of how to use Dropout3d with torch::nn::Dropout3dOptions. See the documentation for ModuleHolder to learn about PyTorch\u2019s module storage semantics. Public Types using Impl = Dropout3dImpl# class Dropout3dImpl : public torch::nn::detail::_DropoutNd\u003cDropout3dImpl\u003e# 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::Dropout3dOptions class to learn what constructor arguments are supported for this module. Example: Dropout3d model(Dropout3dOptions().p(0.42).inplace(true)); Public Functions Tensor forward(Tensor input)# virtual void pretty_print(std::ostream \u0026stream) const override# Pretty prints the Dropout3d module into the given stream. AlphaDropout# class AlphaDropout : public torch::nn::ModuleHolder\u003cAlphaDropoutImpl\u003e# A ModuleHolder subclass for AlphaDropoutImpl. See the documentation for AlphaDropoutImpl class to learn what methods it provides, and examples of how to use AlphaDropout with torch::nn::AlphaDropoutOptions. See the documentation for ModuleHolder to learn about PyTorch\u2019s module storage semantics. Public Types using Impl = AlphaDropoutImpl# class AlphaDropoutImpl : public torch::nn::detail::_DropoutNd\u003cAlphaDropoutImpl\u003e# 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::AlphaDropoutOptions class to learn what constructor arguments are supported for this module. Example: AlphaDropout model(AlphaDropoutOptions(0.2).inplace(true)); Public Functions Tensor forward(const Tensor \u0026input)# virtual void pretty_print(std::ostream \u0026stream) const override# Pretty prints the AlphaDropout module into the given stream. FeatureAlphaDropout# class FeatureAlphaDropout : public torch::nn::ModuleHolder\u003cFeatureAlphaDropoutImpl\u003e# A ModuleHolder subclass for FeatureAlphaDropoutImpl. See the documentation for FeatureAlphaDropoutImpl class to learn what methods it provides, and examples of how to use FeatureAlphaDropout with torch::nn::FeatureAlphaDropoutOptions. See the documentation for ModuleHolder to learn about PyTorch\u2019s module storage semantics. Public Types using Impl = FeatureAlphaDropoutImpl# class FeatureAlphaDropoutImpl : public torch::nn::detail::_DropoutNd\u003cFeatureAlphaDropoutImpl\u003e# See the documentation for torch::nn::FeatureAlphaDropoutOptions class to learn what constructor arguments are supported for this module. Example: FeatureAlphaDropout model(FeatureAlphaDropoutOptions(0.2).inplace(true)); Public Functions Tensor forward(const Tensor \u0026input)# virtual void pretty_print(std::ostream \u0026stream) const override# Pretty prints the FeatureAlphaDropout module into the given stream.",
"author": {
"@type": "Organization",
"name": "PyTorch Contributors",
"url": "https://pytorch.org"
},
"image": "https://pytorch.org/docs/stable/_static/img/pytorch_seo.png",
"mainEntityOfPage": {
"@type": "WebPage",
"@id": "/api/nn/dropout.html"
},
"datePublished": "2023-01-01T00:00:00Z",
"dateModified": "2023-01-01T00:00:00Z"
}
| docsearch:language | en |
| llm:site-type | documentation |
| llm:framework | PyTorch |
| llm:description | Dropout layers in PyTorch C++ — Dropout, Dropout2d, Dropout3d, AlphaDropout, and FeatureAlphaDropout. |
| llm:navigation-file | https://pytorch.org/docs/stable/llms.txt |
| llm:sitemap | https://pytorch.org/docs/stable/sitemap.xml |
| llm:version | main |
| llm:project | PyTorch |
| llm:page-type | documentation |
| og:image | https://docs.pytorch.org/docs/stable/_static/img/pytorch_seo.png |
| None | 3 |
Links:
Viewport: width=device-width, initial-scale=1