flax.linen.Dropout#

class flax.linen.Dropout(rate, broadcast_dims=(), deterministic=None, parent=<flax.linen.module._Sentinel object>, name=None)[source]#

Create a dropout layer.

rate#

the dropout probability. (_not_ the keep rate!)

Type

float

broadcast_dims#

dimensions that will share the same dropout mask

Type

Sequence[int]

deterministic#

if false the inputs are scaled by 1 / (1 - rate) and masked, whereas if true, no mask is applied and the inputs are returned as is.

Type

Optional[bool]

__call__(inputs, deterministic=None)[source]#

Applies a random dropout mask to the input.

Parameters
  • inputs – the inputs that should be randomly masked.

  • deterministic – if false the inputs are scaled by 1 / (1 - rate) and masked, whereas if true, no mask is applied and the inputs are returned as is.

Returns

The masked inputs reweighted to preserve mean.

Methods