|
237 | 237 | "\n",
|
238 | 238 | "### Estimating the Likelihood\n",
|
239 | 239 | "\n",
|
240 |
| - "A VAE defines a probabilistic model $p_\\theta(\\mathbf{x} | \\mathbf{z}) p(\\mathbf{z})$ and we are interested in maximizing the ability of the model to explain the dataset $\\mathcal{D} = \\{\\mathbf{x}_i\\}_{i=1, \\dots, N}$, hence we aim at obtaining the maximum probability $\\log p_\\theta(\\mathcal{D}) = \\sum_{i=1}^N \\log p_\\theta(\\mathbf{x}_i) = \\sum_{i=1}^N \\log \\int_\\mathbf{z} p_\\theta(\\mathbf{x}_i, \\mathbf{z}) d\\mathbf{z} $. Nonetheless the Evidence Lower Bound (ELBO) only provides a lower bound to this quantity. It is common practice to report the average marginal log likelihood: $\\log p_\\theta(\\mathcal{D}) / N$.\n", |
| 240 | + "A VAE defines a probabilistic model $p_\\theta(\\mathbf{x} | \\mathbf{z}) p(\\mathbf{z})$ and we are interested in maximizing the ability of the model to explain the dataset $\\mathcal{D} = \\{\\mathbf{x}_i\\}_{i=1, \\dots, N}$, hence we aim at obtaining the maximum probability $\\log p_\\theta(\\mathcal{D}) = \\sum_{i=1}^N \\log p_\\theta(\\mathbf{x}_i) = \\sum_{i=1}^N \\log \\int_\\mathbf{z} p_\\theta(\\mathbf{x}_i, \\mathbf{z}) d\\mathbf{z} $. However, as discussed previously, the log-likelihood is intractable (marginalization over $\\mathbf{z}$), hence we rely on the Evidence Lower Bound (ELBO) as a proxy, or a tighter bound such as the importance weighted bound (see at the end of the notebook). \n", |
| 241 | + "\n", |
| 242 | + "**NB** It is common practice to report the average marginal log likelihood $\\log p_\\theta(\\mathcal{D}) / N$ and not $\\log p_\\theta(\\mathcal{D})$ directly:\n", |
| 243 | + "\n", |
| 244 | + "$$\\frac{1}{N} \\log p_\\theta(\\mathcal{D}) = \\frac{1}{N} \\sum_i \\log p_\\theta(\\mathbf{x}_i) \\geq \\frac{1}{N} \\sum_i \\operatorname{ELBO}(\\mathbf{x}_i) \\ . $$\n", |
241 | 245 | "\n",
|
242 | 246 | "### Evaluation on Downstream Tasks\n",
|
243 | 247 | "\n",
|
|
825 | 829 | "\n",
|
826 | 830 | "### Exercise 1.\n",
|
827 | 831 | "\n",
|
828 |
| - "- Implement the class `ReparameterizedDiagonalGaussian` (`log_prob()` and `rsample()`).\n", |
829 |
| - "- Import the class `Bernoulli`\n", |
830 |
| - "- Implement the class `VariationalInference` (computation of the `elbo` and `beta_elbo`).\n", |
| 832 | + "1. Implement the class `ReparameterizedDiagonalGaussian` (`log_prob()` and `rsample()`).\n", |
| 833 | + "2. Import the class `Bernoulli`\n", |
| 834 | + "3. Implement the class `VariationalInference` (computation of the `elbo` and `beta_elbo`).\n", |
831 | 835 | "\n",
|
832 | 836 | "### Exercise 2.\n",
|
833 | 837 | "\n",
|
834 |
| - "**Evaluating a VAE model**\n", |
| 838 | + "**Trainnig and Evaluating a VAE model**\n", |
835 | 839 | "\n",
|
836 |
| - "- What available metric can you use to estimate the marginal likelihood ($\\log p_\\theta(\\mathbf{x})$) ?\n", |
837 |
| - "- In the above plots, we display numerous model samples. If you had to pick one plot, which one would you pick to evaluate the quality of a VAE (i.e. using posterior samples $\\mathbf{z} \\sim q_\\phi(\\mathbf{z} | \\mathbf{x})$ or prior samples $\\mathbf{z} \\sim p(\\mathbf{z})$) ? Why?.\n", |
838 |
| - "- How could you exploit the VAE model for classification?\n", |
| 840 | + "1. Why do we use the reparameterization trick?\n", |
| 841 | + "2. What available metric can you use to estimate the marginal likelihood ($p_\\theta(\\mathbf{x})$) ?\n", |
| 842 | + "3. In the above plots, we display numerous model samples. If you had to pick one plot, which one would you pick to evaluate the quality of a VAE (i.e. using posterior samples $\\mathbf{z} \\sim q_\\phi(\\mathbf{z} | \\mathbf{x})$ or prior samples $\\mathbf{z} \\sim p(\\mathbf{z})$) ? Why?.\n", |
| 843 | + "4. How could you exploit the VAE model for classification?\n", |
839 | 844 | "\n",
|
840 | 845 | "**Answers**:\n",
|
841 | 846 | "\n",
|
|
845 | 850 | "\n",
|
846 | 851 | "**Experiment with the VAE model.**\n",
|
847 | 852 | "\n",
|
848 |
| - "- Experiment with the number of layers and activation functions in order to improve the reconstructions and latent representation. What solution did you find the best and why?\n", |
849 |
| - "- Try to increase the number of digit classes in the training set and analyze the learning curves, latent space and reconstructions. For which classes and why does the VAE fail in reconstructing? *HINT: Try the combination: `classes=[0, 1, 4, 9]`, to see how well VAE can separate these digits in the latent representation and reconstructions.*\n", |
850 |
| - "- Increase the number of units in the latent layer. Does it increase the models representational power and how can you see and explain this? How does this affect the quality of the reconstructions?\n", |
| 853 | + "1. Experiment with the number of layers and activation functions in order to improve the reconstructions and latent representation. What solution did you find the best and why?\n", |
| 854 | + "2. Try to increase the number of digit classes in the training set and analyze the learning curves, latent space and reconstructions. For which classes and why does the VAE fail in reconstructing? *HINT: Try the combination: `classes=[0, 1, 4, 9]`, to see how well VAE can separate these digits in the latent representation and reconstructions.*\n", |
| 855 | + "3. Increase the number of units in the latent layer. Does it increase the models representational power and how can you see and explain this? How does this affect the quality of the reconstructions?\n", |
851 | 856 | "\n",
|
852 | 857 | "**Answers**:\n",
|
853 | 858 | "\n",
|
|
0 commit comments