{"id":18556643,"url":"https://github.com/ahmdtaha/simsiam","last_synced_at":"2025-07-22T22:33:54.871Z","repository":{"id":98612398,"uuid":"327903252","full_name":"ahmdtaha/simsiam","owner":"ahmdtaha","description":"Pytorch implementation of  Exploring Simple Siamese Representation Learning","archived":false,"fork":false,"pushed_at":"2023-05-19T01:30:05.000Z","size":370,"stargazers_count":21,"open_issues_count":0,"forks_count":8,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-10T16:53:13.339Z","etag":null,"topics":["deep-learning","deep-neural-networks","python","python3","pytorch","pytorch-implementation","self-supervised","self-supervised-learning","simsiam"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ahmdtaha.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2021-01-08T12:56:42.000Z","updated_at":"2024-12-01T09:25:50.000Z","dependencies_parsed_at":null,"dependency_job_id":"1233cdba-4767-45b0-bbae-b21bc58fa509","html_url":"https://github.com/ahmdtaha/simsiam","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ahmdtaha/simsiam","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahmdtaha%2Fsimsiam","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahmdtaha%2Fsimsiam/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahmdtaha%2Fsimsiam/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahmdtaha%2Fsimsiam/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ahmdtaha","download_url":"https://codeload.github.com/ahmdtaha/simsiam/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahmdtaha%2Fsimsiam/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266586171,"owners_count":23952170,"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","status":"online","status_checked_at":"2025-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["deep-learning","deep-neural-networks","python","python3","pytorch","pytorch-implementation","self-supervised","self-supervised-learning","simsiam"],"created_at":"2024-11-06T21:32:34.137Z","updated_at":"2025-07-22T22:33:54.860Z","avatar_url":"https://github.com/ahmdtaha.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SimSiam\nThis is an _Unofficial_ PyTorch implementation of **Exploring Simple Siamese Representation Learning [1]**. It is highly inspired by [PatrickHua's repository](https://github.com/PatrickHua/SimSiam). The key features in this repository are\n\n1. It supports DistributedDataParallel (DDP) -- not the old fashion DataParallel\n2. It separates the loss function (criteria) from the model. Thus, it is easier to modify the loss function (e.g., add a regularizer) without changing the model.\n3. It automatically switches between the CIFAR-ResNet and the official ResNet based on the training dataset.\n4. The code supports both CIFAR10 and CIFAR100\n\n## Requirements\n\n* Python 3+ [Tested on 3.7]\n* PyTorch 1.x [Tested on 1.7.1]\n\n\n## Usage example\n\nFirst update `constants.py` with your dataset dir and checkpoints dir\n\nTo train a model `python pretrain_main.py` \n\nTo train a linear classifier `python classifier_main.py` -- Make sure to update the path of the [pretrained model](https://github.com/ahmdtaha/simsiam/blob/1975eb6749cc06d1df2a781b4ed9c234ad008c40/classifier_main.py#L107) before running.\n\nThe CIFAR hyperparameters are already hard coded in the python script. However these hyperparameters can be overridden by providing at least one parameter when running the script (e.g., `python pretrain_main.py --arch SimCLR`) \n\nBy default the code leverage DistributedDataParallel. The are two key parameters to identify the training GPUs\n* `--world_size` denotes how many GPUs to use\n* `--base_gpu` denotes what is the start GPU index (0-based). \n  \nFor example if a machine has four GPUs, and user sets world_size=3 and base_gpu=1, the model will be trained on the 2nd, 3rd and 4th GPUs.\n\nThe code logs the training progress in two files\n\n* train_X.log: Assuming base_gpu=X, the file contains text log of the training progress. There are sample log files inside ./sample_runs dir. These are complete/incomplete runs.\n* exp_name.csv: This csv file keeps track of the KNN accuracy at each `--test_interval`\n\nTo train simCLR model, change the [arch parameter](https://github.com/ahmdtaha/simsiam/blob/cd44e3c73b4b70029202f4277266f3b15e7e54f2/pretrain_main.py#L101) to `simCLR`. This code achieves 89.56% KNN accuracy with simCLR (check ./sample_runs dir).\n### Quantitative Evaluation on CIFAR10\n\n|                   | Paper [1] | Ours |\n|-------------------|------------|-------------|\n|     KNN Accracy     |![](./imgs/paper.jpg)|![](./imgs/pretrain_phase.jpg)|\n|     Linear Classifier     |91.8| [90.27](https://github.com/ahmdtaha/simsiam/blob/main/sample_runs/complete_linear_classifier_run.txt) |\n\n\n## Release History\n* 1.0.0\n    * First commit on 8 Jan 2021\n\n### TODO LIST\n* Revise the readme file\n* ~~Test pretrain_main.py with SimCLR~~\n* ~~Add the classifier_main.py~~\n\n## References\n[1] Chen, Xinlei and He, Kaiming. Representation Learning by Learning to Count. arXiv preprint arXiv:2011.10566 \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fahmdtaha%2Fsimsiam","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fahmdtaha%2Fsimsiam","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fahmdtaha%2Fsimsiam/lists"}