{"cells": [{"cell_type": "markdown", "id": "cbcf0f41", "metadata": {"papermill": {"duration": 0.015123, "end_time": "2022-05-03T01:17:51.912530", "exception": false, "start_time": "2022-05-03T01:17:51.897407", "status": "completed"}, "tags": []}, "source": ["\n", "# Tutorial 13: Self-Supervised Contrastive Learning with SimCLR\n", "\n", "* **Author:** Phillip Lippe\n", "* **License:** CC BY-SA\n", "* **Generated:** 2022-05-03T02:43:21.313398\n", "\n", "In this tutorial, we will take a closer look at self-supervised contrastive learning.\n", "Self-supervised learning, or also sometimes called unsupervised learning, describes the scenario where we have given input data, but no accompanying labels to train in a classical supervised way.\n", "However, this data still contains a lot of information from which we can learn: how are the images different from each other?\n", "What patterns are descriptive for certain images?\n", "Can we cluster the images?\n", "To get an insight into these questions, we will implement a popular, simple contrastive learning method, SimCLR, and apply it to the STL10 dataset.\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/13-contrastive-learning.ipynb)\n", "\n", "Give us a \u2b50 [on Github](https://www.github.com/PytorchLightning/pytorch-lightning/)\n", "| Check out [the documentation](https://pytorch-lightning.readthedocs.io/en/stable/)\n", "| Join us [on Slack](https://www.pytorchlightning.ai/community)"]}, {"cell_type": "markdown", "id": "8dfc821d", "metadata": {"papermill": {"duration": 0.011721, "end_time": "2022-05-03T01:17:51.936328", "exception": false, "start_time": "2022-05-03T01:17:51.924607", "status": "completed"}, "tags": []}, "source": ["## Setup\n", "This notebook requires some packages besides pytorch-lightning."]}, {"cell_type": "code", "execution_count": 1, "id": "00a149ee", "metadata": {"colab": {}, "colab_type": "code", "execution": {"iopub.execute_input": "2022-05-03T01:17:51.962905Z", "iopub.status.busy": "2022-05-03T01:17:51.962281Z", "iopub.status.idle": "2022-05-03T01:17:55.701176Z", "shell.execute_reply": "2022-05-03T01:17:55.700261Z"}, "id": "LfrJLKPFyhsK", "lines_to_next_cell": 0, "papermill": {"duration": 3.755451, "end_time": "2022-05-03T01:17:55.703535", "exception": false, "start_time": "2022-05-03T01:17:51.948084", "status": "completed"}, "tags": []}, "outputs": [], "source": ["! pip install --quiet \"torch>=1.8\" \"torchmetrics>=0.7\" \"ipython[notebook]\" \"pytorch-lightning>=1.4\" \"torchvision\" \"setuptools==59.5.0\" \"seaborn\" \"matplotlib\""]}, {"cell_type": "markdown", "id": "472e0e40", "metadata": {"papermill": {"duration": 0.011868, "end_time": "2022-05-03T01:17:55.728779", "exception": false, "start_time": "2022-05-03T01:17:55.716911", "status": "completed"}, "tags": []}, "source": ["