Dropout#

API#

class warp_nn.modules.layers.Dropout(p: float = 0.5, *, requires_grad: bool = True)[source]#

Bases: Module

Randomly zero some of the input values during training.

In training mode (see train()), each value is zeroed with probability \(p\) (independently for each value and forward pass), and the kept values are scaled by \(\frac{1}{1 - p}\). In evaluation mode, the input array is returned as is.

The random number generator is seeded from NumPy’s global random number generator when the module is created.

Parameters:
  • p – The probability of a value to be zeroed.

  • requires_grad – Whether the cached output arrays of the module require gradients.

Raises:

ValueError – If the probability is not in the interval [0, 1].

__call__(
input: array,
) → array[source]#

Forward pass of the module.

Parameters:

input – The input array.

Returns:

The output array, with same shape as the input array (the input array itself in evaluation mode).

Raises:

TypeError – If the input array’s data type is not supported.

to(
device: Device,
) → Dropout[source]#

Move the module to the specified device.

Parameters:

device – The device to move the module to.

Returns:

The module itself.

property p: float[source]#

The probability of a value to be zeroed.