DropBlock2d

class dragon.vm.torch.nn.DropBlock2d(
  p=0.1,
  block_size=7,
  inplace=False
)[source]

Set the 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, 1 - \gamma)) \\ \quad \\ \text{where}\quad \gamma = \frac{p}{\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__(
  p=0.1,
  block_size=7,
  inplace=False
)[source]

Create a DropBlock2d module.

Parameters:
  • p (float, optional, default=0.1) – The dropping ratio.
  • block_size (int, optional, default=7) – The size of a spatial block.
  • inplace (bool, optional, default=False) – Whether to do the operation in-place.