DropBlock2d

class dragon.vm.torch.nn.DropBlock2d(
  kp=0.9,
  block_size=7,
  alpha=1.0,
  decrement=0.0,
  inplace=False
)[source]

Set the spatial blocks to zero randomly. [Ghiasi et.al, 2018].

The DropBlock function is defined as:

\[\text{DropBlock}(x_{ijk} = x_{ijk} * (r_{ik} \sim \mathcal{B}(1, \alpha\gamma)) \\ \quad \\ \text{where}\quad \gamma = \frac{\text{keep\_prob}}{\text{block\_size}^{n}} \frac{\text{feat\_size}^{n}}{(\text{feat\_size} - \text{block\_size} + 1)^n} \]

Examples:

x = torch.ones(1, 3, 4, 4)
m = torch.nn.DropBlock2d(block_size=3)
y = m(x)

__init__

DropBlock2d.__init__(
  kp=0.9,
  block_size=7,
  alpha=1.0,
  decrement=0.0,
  inplace=False
)[source]

Create a DropBlock2d module.

Parameters:
  • kp (float, optional, default=0.9) – The keeping prob.
  • block_size (int, optional, default=7) – The size of a spatial block.
  • alpha (float, optional, default=1.) – The scale factor to \(\gamma\).
  • decrement (float, optional, default=0.) – The decrement value to kp.
  • inplace (bool, optional, default=False) – Whether to do the operation in-place.