

The reparameterization trick
Training needs gradients of an expectation over with respect to . If you draw as a black-box sample, the sampling step has no derivative with respect to , so backpropagation stops there. The reparameterization trick moves the randomness into a variable that does not depend on : The sample now has the same distribution as before. It is also a differentiable function of and the noise , and is drawn without reference to any parameter. For a fixed draw of , the derivatives and are ordinary and the chain rule carries the decoder loss back into the encoder weights. Here in the encoder parameterization above. The implements amortized variational inference, that is, it estimates the posterior parameters over a batch of datapoints and this offers significant boost in the parameter learning. With the encoder defined, the next question is how to train its parameters jointly with the decoder parameters when the true posterior is intractable. The answer is the Evidence Lower Bound (ELBO): a tractable surrogate for the marginal log-likelihood that is derived from the KL divergence between and the true posterior. The derivation and its consequences for joint optimization are covered in the Optimization and the ELBO page.PyTorch reference
Found an error on this page? Report an issue.

