vis4d.op.layer.drop

DropPath (Stochastic Depth) regularization layers.

Modified from timm (https://github.com/huggingface/pytorch-image-models).

Functions

drop_path(x[, drop_prob, training, ...])

Drop path regularizer (Stochastic Depth) per sample.

Classes

DropPath([drop_prob, scale_by_keep])

DropPath regularizer (Stochastic Depth) per sample.

class DropPath(drop_prob=0.0, scale_by_keep=True)[source]

DropPath regularizer (Stochastic Depth) per sample.

Init DropPath.

Parameters:
  • drop_prob (float, optional) – Probability of an item to be masked. Defaults to 0.0.

  • scale_by_keep (bool, optional) – If to scale by keep probability. Defaults to True.

__call__(data)[source]

Applies the layer.

Parameters:

data (Tensor) – (tensor) input shape [N, …]

Return type:

Tensor

forward(x)[source]

Forward pass.

Return type:

Tensor

drop_path(x, drop_prob=0.0, training=False, scale_by_keep=True)[source]

Drop path regularizer (Stochastic Depth) per sample.

Parameters:
  • x (torch.Tensor) – Input tensor of shape (batch_size, …).

  • drop_prob (float, optional) – Probability of an element to be zeroed. Defaults to 0.0.

  • training (bool, optional) – If to apply drop path. Defaults to False.

  • scale_by_keep (bool, optional) – If to scale by keep probability. Defaults to True.

Return type:

Tensor