Skip to content

dropouts

Dropout layers: stochastic depth (DropPath) and the create_dropout factory.

Classes:

  • DropPath –

    Drop paths (Stochastic Depth) per sample (when applied in main path of residual blocks).

Functions:

  • drop_path –

    Drop paths (Stochastic Depth) per sample (when applied in main path of residual blocks),

  • create_dropout –

    Resolve a dropout layer from a name, a class, an instance, or a probability.

DropPath [source]

DropPath(
    drop_prob: float = 0.0, scale_by_keep: bool = True
)

Bases: Module

Drop paths (Stochastic Depth) per sample (when applied in main path of residual blocks).

drop_path [source]

drop_path(
    x: Tensor,
    drop_prob: float = 0.0,
    training: bool = False,
    scale_by_keep: bool = True,
) -> Tensor

Drop paths (Stochastic Depth) per sample (when applied in main path of residual blocks), as described in the paper Deep Networks with Stochastic Depth by Gao Huang, Yu Sun, Zhuang Liu, Daniel Sedra, Kilian Weinberger.

Implementation is taken from original implementation by Ross Wightman in pytorch-image-models.

create_dropout [source]

create_dropout(
    name: Union[DropoutLike, float],
    *args: Any,
    **kwargs: Any,
) -> Module

Resolve a dropout layer from a name, a class, an instance, or a probability.

Parameters:

  • name (Union[DropoutLike, float]) –

    Dropout name (e.g., "dropout", "drop_path"), a class, an instance, or a float probability, which is a shorthand for nn.Dropout(p=name).

  • *args (Any, default: () ) –

    Forwarded to the dropout constructor.

  • **kwargs (Any, default: {} ) –

    Forwarded to the dropout constructor (ignored if name is already an instance).

Returns:

  • Module –

    The instantiated dropout module.