{"id":15031944,"url":"https://github.com/sthalles/simclr","last_synced_at":"2025-05-15T07:04:34.563Z","repository":{"id":39704022,"uuid":"241184407","full_name":"sthalles/SimCLR","owner":"sthalles","description":"PyTorch implementation of SimCLR: A Simple Framework for Contrastive Learning of Visual Representations","archived":false,"fork":false,"pushed_at":"2024-03-04T10:45:52.000Z","size":84436,"stargazers_count":2397,"open_issues_count":29,"forks_count":478,"subscribers_count":20,"default_branch":"master","last_synced_at":"2025-05-15T07:04:19.837Z","etag":null,"topics":["contrastive-loss","deep-learning","machine-learning","pytorch","pytorch-implementation","representation-learning","simclr","torchvision","unsupervised-learning"],"latest_commit_sha":null,"homepage":"https://sthalles.github.io/simple-self-supervised-learning/","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sthalles.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-02-17T18:58:35.000Z","updated_at":"2025-05-14T08:47:37.000Z","dependencies_parsed_at":"2022-07-25T01:02:07.508Z","dependency_job_id":"364c2127-7565-40ff-9d18-e7de70cddd3a","html_url":"https://github.com/sthalles/SimCLR","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sthalles%2FSimCLR","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sthalles%2FSimCLR/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sthalles%2FSimCLR/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sthalles%2FSimCLR/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sthalles","download_url":"https://codeload.github.com/sthalles/SimCLR/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254292039,"owners_count":22046426,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["contrastive-loss","deep-learning","machine-learning","pytorch","pytorch-implementation","representation-learning","simclr","torchvision","unsupervised-learning"],"created_at":"2024-09-24T20:16:57.054Z","updated_at":"2025-05-15T07:04:29.547Z","avatar_url":"https://github.com/sthalles.png","language":"Jupyter Notebook","readme":"# PyTorch SimCLR: A Simple Framework for Contrastive Learning of Visual Representations\n[![DOI](https://zenodo.org/badge/241184407.svg)](https://zenodo.org/badge/latestdoi/241184407)\n\n\n### Blog post with full documentation: [Exploring SimCLR: A Simple Framework for Contrastive Learning of Visual Representations](https://sthalles.github.io/simple-self-supervised-learning/)\n\n![Image of SimCLR Arch](https://sthalles.github.io/assets/contrastive-self-supervised/cover.png)\n\n### See also [PyTorch Implementation for BYOL - Bootstrap Your Own Latent: A New Approach to Self-Supervised Learning](https://github.com/sthalles/PyTorch-BYOL).\n\n## Installation\n\n```\n$ conda env create --name simclr --file env.yml\n$ conda activate simclr\n$ python run.py\n```\n\n## Config file\n\nBefore running SimCLR, make sure you choose the correct running configurations. You can change the running configurations by passing keyword arguments to the ```run.py``` file.\n\n```python\n\n$ python run.py -data ./datasets --dataset-name stl10 --log-every-n-steps 100 --epochs 100 \n\n```\n\nIf you want to run it on CPU (for debugging purposes) use the ```--disable-cuda``` option.\n\nFor 16-bit precision GPU training, there **NO** need to to install [NVIDIA apex](https://github.com/NVIDIA/apex). Just use the ```--fp16_precision``` flag and this implementation will use [Pytorch built in AMP training](https://pytorch.org/docs/stable/notes/amp_examples.html).\n\n## Feature Evaluation\n\nFeature evaluation is done using a linear model protocol. \n\nFirst, we learned features using SimCLR on the ```STL10 unsupervised``` set. Then, we train a linear classifier on top of the frozen features from SimCLR. The linear model is trained on features extracted from the ```STL10 train``` set and evaluated on the ```STL10 test``` set. \n\nCheck the [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://github.com/sthalles/SimCLR/blob/simclr-refactor/feature_eval/mini_batch_logistic_regression_evaluator.ipynb) notebook for reproducibility.\n\nNote that SimCLR benefits from **longer training**.\n\n| Linear Classification      | Dataset | Feature Extractor | Architecture                                                                    | Feature dimensionality | Projection Head dimensionality | Epochs | Top1 % |\n|----------------------------|---------|-------------------|---------------------------------------------------------------------------------|------------------------|--------------------------------|--------|--------|\n| Logistic Regression (Adam) | STL10   | SimCLR            | [ResNet-18](https://drive.google.com/open?id=14_nH2FkyKbt61cieQDiSbBVNP8-gtwgF) | 512                    | 128                            | 100    | 74.45  |\n| Logistic Regression (Adam) | CIFAR10 | SimCLR            | [ResNet-18](https://drive.google.com/open?id=1lc2aoVtrAetGn0PnTkOyFzPCIucOJq7C) | 512                    | 128                            | 100    | 69.82  |\n| Logistic Regression (Adam) | STL10   | SimCLR            | [ResNet-50](https://drive.google.com/open?id=1ByTKAUsdm_X7tLcii6oAEl5qFRqRMZSu) | 2048                   | 128                            | 50     | 70.075 |\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsthalles%2Fsimclr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsthalles%2Fsimclr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsthalles%2Fsimclr/lists"}