{"cells": [{"cell_type": "markdown", "id": "6000551a", "metadata": {"papermill": {"duration": 0.030399, "end_time": "2021-10-10T16:38:20.779892", "exception": false, "start_time": "2021-10-10T16:38:20.749493", "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:** 2021-10-10T18:35:52.598167\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/latest/)\n", "| Join us [on Slack](https://join.slack.com/t/pytorch-lightning/shared_invite/zt-pw5v393p-qRaDgEk24~EjiZNBpSQFgQ)"]}, {"cell_type": "markdown", "id": "c075e657", "metadata": {"papermill": {"duration": 0.028259, "end_time": "2021-10-10T16:38:20.837183", "exception": false, "start_time": "2021-10-10T16:38:20.808924", "status": "completed"}, "tags": []}, "source": ["## Setup\n", "This notebook requires some packages besides pytorch-lightning."]}, {"cell_type": "code", "execution_count": 1, "id": "132c3c36", "metadata": {"colab": {}, "colab_type": "code", "execution": {"iopub.execute_input": "2021-10-10T16:38:20.897899Z", "iopub.status.busy": "2021-10-10T16:38:20.897428Z", "iopub.status.idle": "2021-10-10T16:38:20.900024Z", "shell.execute_reply": "2021-10-10T16:38:20.899479Z"}, "id": "LfrJLKPFyhsK", "lines_to_next_cell": 0, "papermill": {"duration": 0.034648, "end_time": "2021-10-10T16:38:20.900141", "exception": false, "start_time": "2021-10-10T16:38:20.865493", "status": "completed"}, "tags": []}, "outputs": [], "source": ["# ! pip install --quiet \"torch>=1.6, <1.9\" \"matplotlib\" \"pytorch-lightning>=1.3\" \"seaborn\" \"torchvision\" \"torchmetrics>=0.3\""]}, {"cell_type": "markdown", "id": "15410d3c", "metadata": {"papermill": {"duration": 0.02886, "end_time": "2021-10-10T16:38:20.957863", "exception": false, "start_time": "2021-10-10T16:38:20.929003", "status": "completed"}, "tags": []}, "source": ["