DropoutLayer<T>

Layers · AiDotNet.NeuralNetworks.Layers

Implements a dropout layer for neural networks to prevent overfitting.

Inheritance: LayerBase<T> → DropoutLayer<T>

Implements: IShapeContract

For Beginners

Dropout is like randomly turning off some brain cells during training to make the network more robust.

Imagine a team that always practices together:

  • They might develop specific patterns that only work with familiar teammates
  • If some players are absent, the team struggles

Dropout forces the network to work even when some neurons are missing:

  • During training, random neurons are turned off (set to zero)
  • This prevents any single neuron from becoming too important
  • The network learns multiple ways to solve the same problem
  • It’s like practicing with different team combinations each time

During actual use (inference), all neurons are active, but their outputs are slightly reduced to compensate for having more active neurons than during training.

This technique significantly reduces overfitting, which is when a network gets too specialized to its training data and performs poorly on new data.

How It Works

Dropout is a regularization technique that randomly deactivates a fraction of neurons during training, which helps prevent neural networks from overfitting. Overfitting occurs when a model learns patterns that are specific to the training data but don’t generalize well to new data.

Constructors

Constructor Summary
DropoutLayer(double dropoutRate) Initializes a new instance of the DropoutLayer class.

Properties

Property Summary
bool SupportsTraining { get; } Gets a value indicating whether this layer supports training mode.

Methods

Method Summary
IReadOnlyList<OutputAxisContract> OutputAxesFor(int inputRank) Derived from this type’s [TensorLayout] declarations.
OnnxLayerOutputs ConvertToOnnx(OnnxGraphBuilder builder, OnnxLayerInputs inputs) Dropout in inference mode is a no-op.
void ResetState() Resets the internal state of the layer.