{"cells": [{"cell_type": "markdown", "id": "945cfe5e", "metadata": {"papermill": {"duration": 0.009871, "end_time": "2025-04-03T19:23:06.058462", "exception": false, "start_time": "2025-04-03T19:23:06.048591", "status": "completed"}, "tags": []}, "source": ["\n", "# Tutorial 7: Deep Energy-Based Generative Models\n", "\n", "* **Author:** Phillip Lippe\n", "* **License:** CC BY-SA\n", "* **Generated:** 2025-04-03T19:22:59.369888\n", "\n", "In this tutorial, we will look at energy-based deep learning models, and focus on their application as generative models.\n", "Energy models have been a popular tool before the huge deep learning hype around 2012 hit.\n", "However, in recent years, energy-based models have gained increasing attention because of improved training methods and tricks being proposed.\n", "Although they are still in a research stage, they have shown to outperform strong Generative Adversarial Networks\n", "in certain cases which have been the state of the art of generating images\n", "([blog post](https://ajolicoeur.wordpress.com/the-new-contender-to-gans-score-matching-with-langevin-sampling/)about strong energy-based models,\n", "[blog post](https://medium.com/syncedreview/nvidia-open-sources-hyper-realistic-face-generator-stylegan-f346e1a73826) about the power of GANs).\n", "Hence, it is important to be aware of energy-based models, and as the theory can be abstract sometimes,\n", "we will show the idea of energy-based models with a lot of examples.\n", "This notebook is part of a lecture series on Deep Learning at the University of Amsterdam.\n", "The full list of tutorials can be found at https://uvadlc-notebooks.rtfd.io.\n", "\n", "\n", "---\n", "Open in [{height=\"20px\" width=\"117px\"}](https://colab.research.google.com/github/PytorchLightning/lightning-tutorials/blob/publication/.notebooks/course_UvA-DL/07-deep-energy-based-generative-models.ipynb)\n", "\n", "Give us a \u2b50 [on Github](https://www.github.com/Lightning-AI/lightning/)\n", "| Check out [the documentation](https://lightning.ai/docs/)\n", "| Join us [on Discord](https://discord.com/invite/tfXFetEZxv)"]}, {"cell_type": "markdown", "id": "4a407e72", "metadata": {"papermill": {"duration": 0.008896, "end_time": "2025-04-03T19:23:06.075785", "exception": false, "start_time": "2025-04-03T19:23:06.066889", "status": "completed"}, "tags": []}, "source": ["## Setup\n", "This notebook requires some packages besides pytorch-lightning."]}, {"cell_type": "code", "execution_count": 1, "id": "6d4ee18f", "metadata": {"colab": {}, "colab_type": "code", "execution": {"iopub.execute_input": "2025-04-03T19:23:06.093383Z", "iopub.status.busy": "2025-04-03T19:23:06.093150Z", "iopub.status.idle": "2025-04-03T19:23:07.291349Z", "shell.execute_reply": "2025-04-03T19:23:07.289976Z"}, "id": "LfrJLKPFyhsK", "lines_to_next_cell": 0, "papermill": {"duration": 1.209946, "end_time": "2025-04-03T19:23:07.293929", "exception": false, "start_time": "2025-04-03T19:23:06.083983", "status": "completed"}, "tags": []}, "outputs": [{"name": "stdout", "output_type": "stream", "text": ["\u001b[33mWARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager, possibly rendering your system unusable.It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv. Use the --root-user-action option if you know what you are doing and want to suppress this warning.\u001b[0m\u001b[33m\r\n", "\u001b[0m"]}, {"name": "stdout", "output_type": "stream", "text": ["\r\n", "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip is available: \u001b[0m\u001b[31;49m24.2\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m25.0.1\u001b[0m\r\n", "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpython -m pip install --upgrade pip\u001b[0m\r\n"]}], "source": ["! pip install --quiet \"numpy <3.0\" \"tensorboard\" \"torchmetrics >=1.0,<1.8\" \"pytorch-lightning >=2.0,<2.6\" \"torch >=1.8.1,<2.7\" \"torchvision\" \"seaborn\" \"matplotlib\""]}, {"cell_type": "markdown", "id": "c05c196e", "metadata": {"papermill": {"duration": 0.013464, "end_time": "2025-04-03T19:23:07.321630", "exception": false, "start_time": "2025-04-03T19:23:07.308166", "status": "completed"}, "tags": []}, "source": ["