Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
12b033a
Adding an example for Supervised Contrastive Learning
ksalama Oct 18, 2020
00b211a
Removing the notebook and the md files
ksalama Oct 19, 2020
0616833
Update supervised-contrastive-learning.py
ksalama Oct 21, 2020
1a55186
Update supervised-contrastive-learning.py
ksalama Oct 26, 2020
e213499
Update supervised-contrastive-learning.py
ksalama Nov 12, 2020
4899b26
Formatting fixes
fchollet Nov 14, 2020
bc1e59f
Update supervised-contrastive-learning.py
ksalama Nov 20, 2020
2dcea87
Update supervised-contrastive-learning.py
ksalama Nov 20, 2020
4470490
Update supervised-contrastive-learning.py
ksalama Nov 21, 2020
b88380d
Update supervised-contrastive-learning.py
ksalama Nov 21, 2020
0bc6a51
Update supervised-contrastive-learning.py
ksalama Nov 21, 2020
3bc0334
Update supervised-contrastive-learning.py
ksalama Nov 21, 2020
2bde23a
Update supervised-contrastive-learning.py
ksalama Nov 21, 2020
4324445
Update supervised-contrastive-learning.py
ksalama Nov 26, 2020
ab8a4cb
Update supervised-contrastive-learning.py
ksalama Nov 26, 2020
872714f
Update supervised-contrastive-learning.py
ksalama Nov 26, 2020
394fccc
Update supervised-contrastive-learning.py
ksalama Nov 28, 2020
65ebb3e
Format code file using black tool
ksalama Nov 28, 2020
d787ef2
Update supervised-contrastive-learning.py
ksalama Nov 30, 2020
1b05825
Fix typos
ksalama Nov 30, 2020
8b0a692
Update supervised-contrastive-learning.py
ksalama Dec 1, 2020
b61bad2
Add the generated .md and .ipynb files
ksalama Dec 1, 2020
a2fc2d7
Merge pull request #1 from keras-team/master
ksalama Dec 2, 2020
c5cad40
Add an introduction section to the MD file
ksalama Dec 2, 2020
9a529c3
Update examples/vision/md/supervised-contrastive-learning.md
ksalama Dec 2, 2020
c995fb8
Update examples/vision/md/supervised-contrastive-learning.md
ksalama Dec 2, 2020
7264a56
Merge branch 'master' into master
ksalama Dec 3, 2020
ca00e47
Update supervised-contrastive-learning.md
ksalama Dec 3, 2020
b20fe57
Update examples/vision/md/supervised-contrastive-learning.md
ksalama Dec 6, 2020
ba197d2
Update the introduction section
ksalama Dec 6, 2020
f3e9a71
Update the introduction section accordingly
ksalama Dec 6, 2020
8f7ea74
Merge pull request #3 from keras-team/master
ksalama Dec 7, 2020
c65d7e8
Update introduction
ksalama Dec 8, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions examples/vision/ipynb/supervised-contrastive-learning.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"\n",
"[Supervised Contrastive Learning](https://arxiv.org/abs/2004.11362)\n",
"(Prannay Khosla et al.) is a training methodology that outperforms\n",
"plain crossentropy-supervised training on classification tasks.\n",
"supervised training with crossentropy on classification tasks.\n",
"\n",
"Essentially, training an image classification model with Supervised Contrastive\n",
"Learning is performed in two phases:\n",
Expand All @@ -34,7 +34,7 @@
"representations of images in different classes.\n",
"2. Training a classifier on top of the frozen encoder.\n",
"\n",
"Note that this example requires TensorFlow Addons, which you can install via:\n",
"Note that this example requires [TensorFlow Addons](https://www.tensorflow.org/addons), which you can install using the following command:\n",
"\n",
"```python\n",
"pip install tensorflow-addons\n",
Expand Down Expand Up @@ -408,4 +408,4 @@
},
"nbformat": 4,
"nbformat_minor": 0
}
}
12 changes: 5 additions & 7 deletions examples/vision/md/supervised-contrastive-learning.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,11 @@
<img class="k-inline-icon" src="https://colab.research.google.com/img/colab_favicon.ico"/> [**View in Colab**](https://colab.research.google.com/github/keras-team/keras-io/blob/master/examples/vision/ipynb/supervised-contrastive-learning.ipynb) <span class="k-dot">•</span><img class="k-inline-icon" src="https://github.com/favicon.ico"/> [**GitHub source**](https://github.com/keras-team/keras-io/blob/master/examples/vision/supervised-contrastive-learning.py)



---
## Introduction

[Supervised Contrastive Learning](https://arxiv.org/abs/2004.11362)
(Prannay Khosla et al.) is a training methodology that outperforms
plain crossentropy-supervised training on classification tasks.
supervised training with crossentropy on classification tasks.

Essentially, training an image classification model with Supervised Contrastive
Learning is performed in two phases:
Expand All @@ -25,15 +23,16 @@ that representations of images in the same class will be more similar compared t
representations of images in different classes.
2. Training a classifier on top of the frozen encoder.

Note that this example requires TensorFlow Addons, which you can install via:

Note that this example requires [TensorFlow Addons](https://www.tensorflow.org/addons), which you can install using
the following command:

```python
pip install tensorflow-addons
```

---
## Setup

## Setup

```python
import tensorflow as tf
Expand All @@ -43,7 +42,6 @@ from tensorflow import keras
from tensorflow.keras import layers
```

---
## Prepare the data


Expand Down
5 changes: 3 additions & 2 deletions examples/vision/supervised-contrastive-learning.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

[Supervised Contrastive Learning](https://arxiv.org/abs/2004.11362)
(Prannay Khosla et al.) is a training methodology that outperforms
plain crossentropy-supervised training on classification tasks.
supervised training with crossentropy on classification tasks.

Essentially, training an image classification model with Supervised Contrastive
Learning is performed in two phases:
Expand All @@ -20,7 +20,8 @@
representations of images in different classes.
2. Training a classifier on top of the frozen encoder.

Note that this example requires TensorFlow Addons, which you can install via:
Note that this example requires [TensorFlow Addons](https://www.tensorflow.org/addons),
which you can install using the following command:

```python
pip install tensorflow-addons
Expand Down