Dropout
simplegrad.nn.dropout.Dropout
Bases: Module
Apply dropout regularization during training.
During training, randomly zeroes elements of the input tensor with
probability p. Disabled automatically in evaluation mode.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
p
|
float
|
Probability of zeroing each element. Must be in |
0.5
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in simplegrad/nn/dropout.py
forward(x: Tensor) -> Tensor
Apply dropout to the input.
In eval mode (or when p=0), the input passes through unchanged.
The random mask is generated at realize time, so this method is
compatible with lazy execution mode.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Tensor
|
Input tensor. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Tensor with random elements zeroed (training) or unchanged (eval). |