How does dropout2d works in CNN?

Hi Community,
I would like to know how does dropout2d works? Does the weights are made to zero or output of activation of previous layer is made to zero in dropout?

Dropout layers masks the activations, not the weights or a layer:

drop = nn.Dropout2d()
x = torch.randn(1, 3, 4, 4)
out = drop(x)
print(out)
# tensor([[[[-1.2433, -2.1234, -1.8535,  0.1276],
#           [ 5.8782, -2.1130,  1.8116,  1.3773],
#           [-2.0260, -1.5322,  1.3397,  0.8360],
#           [ 0.8796, -0.7228, -0.7606, -4.3226]],

#          [[ 0.0000, -0.0000, -0.0000,  0.0000],
#           [-0.0000,  0.0000, -0.0000,  0.0000],
#           [-0.0000,  0.0000,  0.0000,  0.0000],
#           [-0.0000,  0.0000,  0.0000, -0.0000]],

#          [[-0.0000,  0.0000,  0.0000, -0.0000],
#           [ 0.0000,  0.0000,  0.0000, -0.0000],
#           [ 0.0000,  0.0000, -0.0000, -0.0000],
#           [ 0.0000, -0.0000,  0.0000, -0.0000]]]])
1 Like