drop_block

dragon.nn.drop_block(
  inputs,
  ratio=0.1,
  block_size=1,
  data_format='NCHW',
  inplace=False,
  **kwargs
)[source]

Set the blocks over input 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{\text{ratio}}{\text{block\_size}^{n}} \frac{\text{feat\_size}^{n}}{(\text{feat\_size} - \text{block\_size} + 1)^n} \]

Examples:

x = dragon.ones((1, 3, 5, 5), 'float32')
print(dragon.nn.drop_block(x, ratio=0.5, block_size=3))
Parameters:
  • inputs (dragon.Tensor) – The input tensor.
  • ratio (Union[float, dragon.Tensor], optional, default=0.1) – The probability to zero a block.
  • block_size (int, optional, default=7) – The spatial block size.
  • data_format (str, optional, default='NCHW') – 'NCHW' or 'NHWC'.
  • inplace (bool, optional, default=False) – Call in-place or return a new tensor.
Returns:

dragon.Tensor – The output tensor.