Skip to content
BIASED

The KL term of the VAE loss

Structure check. The site checks the solution structure. Python is not executed.

Finish kl_per_dim: given mu and logvar =log⁡σ2= \log\sigma^2, return the element-wise DKL(N(μ,σ2) ∥ N(0,1))D_{\mathrm{KL}}\big(\mathcal N(\mu, \sigma^2)\,\|\,\mathcal N(0, 1)\big) — one term of the sum over latent dimensions. Summing over dim=1 and averaging over the batch happen outside.

Use operators and the functions torch.exp, torch.log: method calls such as logvar.exp() are not understood by the check yet.

The reparameterization trick