Skip to content
class

DropBlockBackward

DropBlockBackward

Autograd node for DropBlock — structured spatial dropout for 4-D convolutional feature maps (Ghiasi, Lin & Le 2018).

A sparse seed mask of Bernoulli samples is generated at the per-element rate γ=p⋅HWB2(H−B+1)(W−B+1)+ε\gamma = p \cdot \dfrac{H W}{B^2 (H - B + 1)(W - B + 1) + \varepsilon} (with BB = block_size) and then dilated by the backend into contiguous B×BB \times B keep blocks so that whole spatial patches are zeroed together rather than uncorrelated single pixels. This is far more effective than element-wise dropout on convolutional outputs where neighbouring pixels are strongly correlated.

Attributes

schema_v1OpSchema
Registered schema (name "drop_block", version 1, AmpPolicy::KeepInput).
p_double
Target block-level drop rate.
mask_Storage
The dilated {0,1}\{0, 1\} keep mask, same shape as the input, saved for the backward multiply.

Static methods

1
static

forward

→TensorImplPtr
int forward(const int & a, int block_size, double p, double eps, Generator * gen)

Sample the seed mask, dilate into blocks, and apply.

Parameters

aTensorImplPtr
4-D input tensor of shape (N, C, H, W).
block_sizestd::int64_t
Side length of each dropped block. Must be strictly positive.
pdouble
Target block-level drop probability in [0,1)[0, 1).
epsdouble
Numerical guard added to the denominator when computing γ\gamma to avoid division by zero on small spatial extents.
Optional RNG (see DropoutBackward).

Returns

TensorImplPtr

Output tensor with the same shape as a.

Raises

LucidError
If a is not 4-D, p is outside [0,1)[0, 1), block_size <= 0, or deterministic mode is on without a Generator.

Methods

3
fn

apply

int apply(int grad_out)

Backward: multiply grad_out by the saved keep mask.

fn

apply_for_graph

int apply_for_graph(const int & grad_out)
fn

release_own_saved

void release_own_saved()