The explanation follows Algorithm 1 of the paper. DropBlock has two main settings: the block side length block_size, and the keep probability keep_prob, which has the same meaning as in Dropout. The mask is generated separately for each channel (in the paper this worked better than sharing one mask across all channels).
- At inference, return the feature A as is (do nothing).
- During training, first decide for each pixel, with probability γ, whether it becomes a block center (seed). Seeds are chosen only from the region where the block fits inside the feature map (a square with side feat_size−block_size+1).
Mi,j∼Bernoulli(γ)
- Around each chosen seed, set the mask to 0 over a square of side
block_size. Blocks may overlap.
- Apply the mask to the feature.
A←A×M
- To keep the values from shrinking because of the dropped units, multiply by the ratio of the number of mask elements to the number of ones to normalize the magnitude.
A←A×count_ones(M)count(M)
Choosing γ: The paper does not set γ directly but computes it from keep_prob. One seed drops block_size2 pixels, and seeds can only be chosen inside the valid region, so γ is reduced with the following formula so that the fraction of dropped pixels is close to 1−keep_prob (feat_size is the side length of the feature map).
γ=block_size21−keep_prob⋅(feat_size−block_size+1)2feat_size2
For example, with feat_size=14, block_size=7, and keep_prob=0.9, γ=490.1⋅64196=0.00625. On average 0.4 of the 8×8=64 eligible pixels become seeds, and each seed drops 49 pixels, so on average 19.6 pixels are dropped, about 10% of the total (196 pixels). Because blocks can overlap, this formula is an approximation.
Lower keep_prob gradually during training (Scheduled DropBlock). According to the paper, dropping with a small keep_prob from the start hurts the early stage of training and does not work well. Decreasing keep_prob linearly from 1 to the target value improved accuracy for many keep_prob values and made the results less sensitive to the choice of value.