represents a net layer that sets its input elements to zero with probability 0.5 during training.
DropoutLayer[p]
sets its input elements to zero with probability p during training.
DropoutLayer
represents a net layer that sets its input elements to zero with probability 0.5 during training.
DropoutLayer[p]
sets its input elements to zero with probability p during training.
Details and Options
- DropoutLayer is commonly used as a form of neural network regularization.
- DropoutLayer is typically used inside NetChain, NetGraph, etc.
- The following optional parameters can be included:
-
Method "Dropout" dropout method to use "OutputPorts" "Output" output ports - Possible explicit settings for the Method option include:
-
"AlphaDropout" keeps the mean and variance of the input constant; designed to be used together with the ElementwiseLayer["SELU"] activation "Dropout" sets the input elements to zero with probability p during training, multiplying the remainder by 1/(1-p) - Possible settings for the "OutputPorts" option include:
-
"BinaryMask" binary mask applied to input data "Output" output of the dropout {port1,…} a list of valid ports - DropoutLayer exposes the following ports for use in NetGraph etc.:
-
"Input" an array or sequence of arrays of arbitrary rank "Output" an array or sequence of arrays of arbitrary rank - DropoutLayer normally infers the dimensions of its input from its context in NetChain etc. To specify the dimensions explicitly as {n1,n2,…}, use DropoutLayer["Input"->{n1,n2,…}].
- DropoutLayer[…][input] explicitly computes the output from applying the layer.
- DropoutLayer[…][{input1,input2,…}] explicitly computes outputs for each of the inputi.
- When given a NumericArray as input, the output will be a NumericArray.
- DropoutLayer only randomly sets input elements to zero during training. During evaluation, DropoutLayer leaves the input unchanged, unless NetEvaluationMode->"Train" is specified when applying the layer.
- Options[DropoutLayer] gives the list of default options to construct the layer. Options[DropoutLayer[…]] gives the list of default options to evaluate the layer on some data.
- Information[DropoutLayer[…]] gives a report about the layer.
- Information[DropoutLayer[…],prop] gives the value of the property prop of DropoutLayer[…]. Possible properties are the same as for NetGraph.
Examples
open all close allBasic Examples (1)
Create a DropoutLayer:
drop = DropoutLayer[]Apply it to an input, which remains unchanged:
drop[{1, 2, 3, 4, 5}]Use NetEvaluationMode to force training behavior of DropoutLayer:
drop[{1, 2, 3, 4, 5}, NetEvaluationMode -> "Train"]Scope (2)
Create a DropoutLayer with a specific probability:
drop = DropoutLayer[0.8]Apply it to input data, which leaves the input unchanged:
drop[{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}]Apply it to input data, specifying that training behavior be used:
drop[{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, NetEvaluationMode -> "Train"]Create a DropoutLayer that takes an RGB image and returns an RGB image:
drop = DropoutLayer[0.95, "Input" -> NetEncoder["Image"], "Output" -> NetDecoder["Image"]]The DropoutLayer acts on the image represented by a rank-3 array by randomly and independently zeroing the individual color components of each pixel:
drop[[image], NetEvaluationMode -> "Train"]Options (2)
Method (1)
Create a DropoutLayer using "AlphaDropout" as the dropout method:
drop = DropoutLayer[Method -> "AlphaDropout"]Apply it to input data, specifying that training behavior be used:
drop[{1, 2, 3, 4, 5, 6, 7}, NetEvaluationMode -> "Train"]If the input data has a mean of 0 and a variance of 1, then the output will have the same mean and variance:
data = RandomVariate[NormalDistribution[0, 1], 20000];out = drop[data, NetEvaluationMode -> "Train"];Variance@outMean@outThis is not the case for the standard dropout method:
out2 = DropoutLayer[][data, NetEvaluationMode -> "Train"];Mean@out2Variance@out2"OutputPorts" (1)
Create a DropoutLayer that yields the binary mask besides the output:
drop = DropoutLayer["OutputPorts" -> {"Output", "BinaryMask"}]drop[{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}]Apply it to input data, specifying that training behavior be used:
drop[{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, NetEvaluationMode -> "Train"]Properties & Relations (1)
DropoutLayer can be used between recurrent layers in a NetChain to perform regularization. A typical network used to classify sentences might incorporate a DropoutLayer as follows:
NetChain[{EmbeddingLayer[20], GatedRecurrentLayer[100], DropoutLayer[0.2], GatedRecurrentLayer[100], SequenceLastLayer[], LinearLayer[{}], LogisticSigmoid}, "Input" -> NetEncoder["Characters"], "Output" -> NetDecoder["Boolean"]]More sophisticated forms of dropout are possible by using the "Dropout" option of recurrent layers directly:
gru = GatedRecurrentLayer[100, "Dropout" -> {"VariationalInput" -> 0.2, "StateUpdate" -> 0.1}]NetChain[{EmbeddingLayer[20], gru, gru, SequenceLastLayer[], LinearLayer[{}], LogisticSigmoid}, "Input" -> NetEncoder["Characters"], "Output" -> NetDecoder["Boolean"]]Possible Issues (1)
By default, any randomness invoked by NetEvaluationMode->"Train" is not affected by SeedRandom and BlockRandom:
drop = DropoutLayer[]Table[BlockRandom[drop[{1, 2, 3, 4}, NetEvaluationMode -> "Train"]], 6]Use option RandomSeedingInherited to change this behavior:
Table[BlockRandom[drop[{1, 2, 3, 4}, NetEvaluationMode -> "Train",
RandomSeeding -> Inherited]], 6]Use option RandomSeeding to control the randomness:
Table[drop[{1, 2, 3, 4}, NetEvaluationMode -> "Train", RandomSeeding -> 123], 6]Tech Notes
Related Guides
Text
Wolfram Research (2016), DropoutLayer, Wolfram Language function, https://reference.wolfram.com/language/ref/DropoutLayer.html (updated 2020).
CMS
Wolfram Language. 2016. "DropoutLayer." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2020. https://reference.wolfram.com/language/ref/DropoutLayer.html.
APA
Wolfram Language. (2016). DropoutLayer. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/DropoutLayer.html
BibTeX
@misc{reference.wolfram_2026_dropoutlayer, author="Wolfram Research", title="{DropoutLayer}", year="2020", howpublished="\url{https://reference.wolfram.com/language/ref/DropoutLayer.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_dropoutlayer, organization={Wolfram Research}, title={DropoutLayer}, year={2020}, url={https://reference.wolfram.com/language/ref/DropoutLayer.html}, note=[Accessed: 13-June-2026]}