https://github.com/sthalles/simclr-tensorflow
TensorFlow Implementation of SimCLR: A Simple Framework for Contrastive Learning of Visual Representations
https://github.com/sthalles/simclr-tensorflow
contrastive-learning contrastive-loss representation-learning self-supervised-learning simclr tensorflow unsupervised-learning
Last synced: 6 months ago
JSON representation
TensorFlow Implementation of SimCLR: A Simple Framework for Contrastive Learning of Visual Representations
- Host: GitHub
- URL: https://github.com/sthalles/simclr-tensorflow
- Owner: sthalles
- Created: 2020-03-09T10:44:18.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-03-10T10:53:19.000Z (over 5 years ago)
- Last Synced: 2025-03-22T21:51:11.380Z (7 months ago)
- Topics: contrastive-learning, contrastive-loss, representation-learning, self-supervised-learning, simclr, tensorflow, unsupervised-learning
- Language: Python
- Homepage: https://sthalles.github.io/simple-self-supervised-learning/
- Size: 32.2 KB
- Stars: 27
- Watchers: 2
- Forks: 7
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# TensorFlow implementation of SimCLR: A Simple Framework for Contrastive Learning of Visual Representations
## Still under development!!
### Blog post with full documentation: [Exploring SimCLR: A Simple Framework for Contrastive Learning of Visual Representations](https://sthalles.github.io/simple-self-supervised-learning/)
#### For a Pytorch Implementation: [PyTorch SimCLR](https://github.com/sthalles/SimCLR)

## Dependencies
- tensorflow 2.x
## Config file
Before running SimCLR, make sure you choose the correct running configurations on the ```config.yaml``` file.
```yaml
batch_size: 256 # A batch size of N, produces 2 * (N-1) negative samples. Original implementation uses a batch size of 8192
out_dim: 64 # Output dimensionality of the embedding vector z. Original implementation uses 2048
s: 1
temperature: 0.5 # Temperature parameter for the contrastive objective
base_convnet: "resnet18" # The ConvNet base model. Choose one of: "resnet18 or resnet50". Original implementation uses resnet50
use_cosine_similarity: True # Distance metric for contrastive loss. If False, uses dot product
epochs: 40 # Number of epochs to train
num_workers: 4 # Number of workers for the data loader
```## Feature Evaluation
Feature evaluation is done using a linear model protocol. Feature are learned using the ```STL10 unsupervised``` set and evaluated in the train/test splits;
Check the ```feature_eval/FeatureEvaluation.ipynb``` notebook for reproducebility.
| Feature Extractor | Method | Architecture | Top 1 |
|:-------------------:|:------------:|:------------:|:-----:|
| Logistic Regression | PCA Features | - | - |
| KNN | PCA Features | - | - |
| Logistic Regression | SimCLR | ResNet-18 | - |
| KNN | SimCLR | ResNet-18 | - |## Download pre-trained model
---