Explaining dropout as ensemble of thinned networks
Dropout trains an exponential ensemble of subnetworks defined by independent Bernoulli masks that drop units randomly, sharing weights across all these submodels by minimizing the expected loss over all masks. At test time, exact averaging is infeasible, so scaling weights by the keep probability approximates the ensemble average because the expected output of a masked linear layer equals the output with scaled weights.
What people usually mean when they say “dropout is like an ensemble” is the following.
Fix an architecture and a set of weights (\theta). If you take a standard multilayer perceptron and, for each hidden unit, flip an independent Bernoulli coin, you obtain a “thinned” version of the original network in which the units with a zero coin‑flip and all of their incoming and outgoing connections have been deleted. There are (2^{N}) such thinnings if there are (N) units subject to dropout. If you write (f(x;\theta,m)) for the output of the network with weights (\theta) and a particular mask (m\in{0,1}^N), then the dropout objective is
[
J(\theta);=;\mathbb{E}_{m\sim\mathrm{Bernoulli}(p)^N}\big[L\big(f(x;\theta,m),y\big)\big],
]
the expected loss when a random mask is applied. Expanding the expectation shows that this is just the average loss over all (2^N) thinned networks, weighted by the probability of their mask under the Bernoulli product distribution. The stochastic algorithm used in practice – draw a mask (m), do a forward and backward pass, update (\theta) – is an unbiased Monte Carlo estimator of (\nabla J(\theta)), so over the course of training you are pushing down the average loss of the entire exponential–size ensemble, with a single shared set of parameters (\theta).
At test time you would, in principle, like to combine the predictions of this ensemble,
[
\bar{f}(x);=;\mathbb{E}{m}[f(x;\theta^{\star},m)],
]
because model averaging reduces variance. Computing (\bar{f}) exactly is impossible for large (N), but there is a simple approximation. In the linear parts of the network the expectation commutes with the computation. For example, with a single linear layer (h = W(x\odot m)) one has
[
\mathbb{E}{m}[h] ;=; \mathbb{E}_{m}[W(x\odot m)] ;=; W(\mathbb{E}[m]\odot x) ;=; p,W x,
]
because (\mathbb{E}[m_i]=p). Thus the mean prediction of all of the thinned models on that layer can be obtained by using the full layer with its weights scaled by (p). Propagating this argument through the network gives the “weight–scaling inference rule”: either multiply each unit’s output by its keep‑probability at test time, or equivalently, multiply each set of outgoing weights by the keep‑probability. An alternative convention, often called “inverted dropout”, applies the factor (1/p) during training so that the activations have the same scale at test time and no explicit scaling is needed.
For purely linear models the equality (\mathbb{E}_{m}[f(x;\theta,m)]=f(x;p\theta)) is exact; for networks with non‑linearities it is only approximate, but in practice using the scaled full network at test time is a good approximation to averaging over the exponentially many thinned subnetworks.