facebookresearch / suncet

Code to reproduce the results in the FAIR research papers "Semi-Supervised Learning of Visual Features by Non-Parametrically Predicting View Assignments with Support Samples" https://arxiv.org/abs/2104.13963 and "Supervision Accelerates Pre-training in Contrastive Semi-Supervised Learning of Visual Representations" https://arxiv.org/abs/2006.10803
MIT License
488 stars 67 forks source link

`ClassStratifiedSampler` #22

Closed jmarrietar closed 2 years ago

jmarrietar commented 2 years ago

Hi!

I have a question regarding ClassStratifiedSampler is sampler very necessary?. For my problem, I have only 2 classes. From my understanding of the code I would need to change the variable labels_matrix and make it one-hot labels for my not sampled data, is that correct?

Also a little related with https://github.com/facebookresearch/suncet/issues/17 as I am trying to re-structure the code to run on TPU and having some problems with that sampler.

Thanks!.

MidoAssran commented 2 years ago

Hey @jmarrietar,

You are absolutely correct. If you don't use ClassStratifiedSampler then you just need to change labels_matrix and make it one-hot labels for your support samples. For example, when you sample your supervised support samples with your regular sampler, it would probably just return something like support_imgs, targets = next(supervised_sampler), and then you can just say labels_matrix = one_hot(targets).

For the record, I do know of someone working on a Google Colab implementation in tensorflow, but not sure where that's at right now. Will keep you posted if I hear more about it.