GithubHelp home page GithubHelp logo

ayulockin / swav-tf Goto Github PK

View Code? Open in Web Editor NEW
86.0 5.0 12.0 21.06 MB

TensorFlow implementation of "Unsupervised Learning of Visual Features by Contrasting Cluster Assignments".

Home Page: https://app.wandb.ai/authors/swav-tf/reports/Unsupervised-Visual-Representation-Learning-with-SwAV--VmlldzoyMjg3Mzg

License: Apache License 2.0

Jupyter Notebook 99.90% Python 0.10%
tensorflow2 keras tensorflow representation-learning self-supervised-learning augmentation contrastive-learning

swav-tf's Introduction

Hello, I'm Ayush Thakur ๐Ÿ‘‹

ayulockin

Thakur's Twitter Thakur's Linkdein Thakur's Github

  • ๐Ÿ”ญ Iโ€™m currently working at Weights and Biases as a Machine Learning Engineer.
  • ๐Ÿ“ฃ I am a Google Developer Expert in Machine Learning (TensorFlow Core).
  • ๐ŸŒป I am a Kaggle Notebooks Master. Here's my Kaggle profile.
  • ๐ŸŒฑ I create contents on deep learning. Find some of my work here.
  • ๐Ÿช‚ I build MLOps pipeline for open-source repositories like Keras, OpenMMLab repos, Meta repo, etc.
  • ๐ŸŒž Currently interested in Unsupervised Visual Representation Learning.
  • ๐Ÿ‘ฏ I would love to collaborate on any computer vision project. (It should not be face detection)
  • โœจ I love good discussions. Best way to reach me: Twitter - @ayushthakur0
  • ๐Ÿ˜„ Pronouns: He/His
  • โšก Fun fact: I love watching anime. (Naruto is all time fav. One Piece is love. Jujutsu Kaisen is ๐Ÿ”ฅ. I can keep talking...)

GitHub Streak Stats

Show some โค๏ธ by starring some of the repositories!

swav-tf's People

Contributors

ayulockin avatar sayakpaul avatar spidersaw avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

swav-tf's Issues

Fine-tuning with 10% labeled data with SwAV-learned embeddings

@ayulockin

From the fine-tuning notebooks (10 epochs and 40 epochs) I have the following observations:

  • With SwAV embeddings from 10 epochs, the model tends to have a pretty large overfit margin (note that this after the final fine-tuning is done):

    image

Final progress (with EarlyStopping) -

loss: 0.5366 - acc: 0.8120 - val_loss: 1.8524 - val_acc: 0.5000

  • With the same embeddings along with augmentation, the model seems to recover the large gap -

    image

Final progress (with EarlyStopping) -

loss: 0.9433 - acc: 0.6104 - val_loss: 1.2685 - val_acc: 0.5455

  • Going in the same order of experiments, with embeddings from 40 epochs, the following is what we get after the final fine-tuning (without any augmentation) -

    image

Final progress -

loss: 1.3076 - acc: 0.5613 - val_loss: 1.7242 - val_acc: 0.4800

Note that the model does not suffer from large overfitting gap in this case.

  • With augmentation, we get -

    image

Final progress -

loss: 0.9239 - acc: 0.6621 - val_loss: 1.3685 - val_acc: 0.5291

This performance is almost similar to what we got in this setting with the embeddings from 10 epochs.

Classify a single image

Hello :)
How could I predict the label of a single new image after the SwAV training and linear evaluation ?
Thank you!

Pointers on Train_Step_And_Loss.ipynb

  • We need to trace what is non-trainable and what is. In the main SwAV code, all the variables with no_grad tag are basically non-trainable.

  • Did not get this part - "## crossentropy loss between code and p, assuming that code is to be precited from the assigned cluster. if wrong then logits will be label and vice versa". Are you meaning that the logits and labels in criterion will be swapped? If so, how?

  • I think it might be even better to just replicate the following as the authors have done in here. What do you think?

    image

  • Two normalizations. First, they normalize the embeddings they get from the RN50 backbone, then they pass it through a linear layer (prototype). While training they again normalize this prototype vector.

[QUESTION] Difference 10-epochs, 40-epochs

Hi Ayush and Sayak,
I read your blog on wandb and find it interesting to see the performance on a relatively small dataset. Great work!

I am trying to reproduce your results with the official swAV-implementation. Though I only reach the 10-epochs plateau (~2.7).

I was wondering what are the difference between both runs? I found the following, did I miss any?

  • projection to prototype architecture
  • PolynomialDecay
  • ... further?

Just curious, if you achieved the same results with the original pytorch implementation?

Thanks in advance :)

image loaders don't produce augmentations from the same image

Hi, I was looking into the notebook initial_notebooks/MultiCropDataset_Architecture.ipynb

and I am curious, when visualizing the images from im1, im2, im3 tensors
why do they contain different images,
for instance, I would expect
im1[0], im2[0], im3[0]. to be different augmentations from the same image, but this is not the case here. I am probably getting something wrong.

model loss plateau's after 2 epochs

Hi, first off, thanks for the wonderful effort in converting this code from pyT to TF ..i was running your baseline model and looks like post epoch 2 where the loss is around 2.4 , the loss either doesn't go down or goes down almost negligibly till about epoch 10 .. and even at 10 its about 2.35/2.36 .. in your experiments have you noticed them go down in a 40 epoch run ? logically it doesn't make sense that once it plateaus more epochs can solve the problem ..

i am planning to use this for a totally different domain and dataset ( which of course, i will post on a public link AND ref ur work ) and would appreciate any thoughts

Pointers on Minimal_Sinkhorn_Knopp.ipynb

This notebook presents a minimal implementation for optimal transport using the Sinkhorn Knopp algorithm. In the context of SwAV this is basically needed in order to compute the cluster assignments from prototypes.

Referred from the following:

image

(A.1 from the SwAV paper)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.