Code

Algorithm for a Dropout Layer

A dropout layer can be implemented algorithmically from scratch by first checking if the dropout probability pp equals 11; if so, it immediately returns a tensor of zeros. For p<1p < 1, it generates a boolean mask by evaluating where a tensor of uniform random numbers U[0,1]U[0, 1] is strictly greater than pp. This boolean mask is cast to a floating-point format, multiplied element-wise with the input tensor, and divided by 1p1 - p to rescale the surviving elements.

0

1

Updated 2026-05-07

Contributors are:

Who are from:

Tags

D2L

Dive into Deep Learning @ D2L