Skip to content

Commit

Permalink
Add an introduction section to the MD file (#321)
Browse files Browse the repository at this point in the history
* Adding an example for Supervised Contrastive Learning

* Removing the notebook and the md files

* Update supervised-contrastive-learning.py

* Update supervised-contrastive-learning.py

* Update supervised-contrastive-learning.py

* Formatting fixes

* Update supervised-contrastive-learning.py

* Update supervised-contrastive-learning.py

* Update supervised-contrastive-learning.py

* Update supervised-contrastive-learning.py

* Update supervised-contrastive-learning.py

* Update supervised-contrastive-learning.py

* Update supervised-contrastive-learning.py

* Update supervised-contrastive-learning.py

* Update supervised-contrastive-learning.py

* Update supervised-contrastive-learning.py

* Update supervised-contrastive-learning.py

* Format code file using black tool

* Update supervised-contrastive-learning.py

* Fix typos

* Update supervised-contrastive-learning.py

* Add the generated .md and .ipynb files

* Add an introduction section to the MD file

* Update examples/vision/md/supervised-contrastive-learning.md

Co-authored-by: 8bitmp3 <19637339+8bitmp3@users.noreply.github.com>

* Update examples/vision/md/supervised-contrastive-learning.md

Co-authored-by: 8bitmp3 <19637339+8bitmp3@users.noreply.github.com>

* Update supervised-contrastive-learning.md

* Update examples/vision/md/supervised-contrastive-learning.md

Co-authored-by: 8bitmp3 <19637339+8bitmp3@users.noreply.github.com>

* Update the introduction section

* Update the introduction section accordingly

* Update introduction

Co-authored-by: François Chollet <francois.chollet@gmail.com>
Co-authored-by: 8bitmp3 <19637339+8bitmp3@users.noreply.github.com>
  • Loading branch information
3 people authored Dec 8, 2020
1 parent a21a7f8 commit de7ea52
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
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

0 comments on commit de7ea52

Please sign in to comment.