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.
- Parameters
rate (float) –
broadcast_dims (Sequence[int]) –
deterministic (Optional[bool]) –
parent (Optional[Union[Type[flax.linen.module.Module], Type[flax.core.scope.Scope], Type[flax.linen.module._Sentinel]]]) –
name (str) –
- Return type
None
- 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 (Optional[bool]) – 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