Skip to content
This repository was archived by the owner on Apr 17, 2023. It is now read-only.

[OTX] Add SupCon recipes for classification task#102

Merged
arrufat merged 7 commits intootxfrom
feature/supcon-cls
Dec 14, 2022
Merged

[OTX] Add SupCon recipes for classification task#102
arrufat merged 7 commits intootxfrom
feature/supcon-cls

Conversation

@arrufat
Copy link
Copy Markdown

@arrufat arrufat commented Dec 8, 2022

This PR contains recipes for training models using a SupCon-like style.

These recipes aim to increase the current classification baseline when the data is scarce.

Procedure:

  • Train a model with two heads:
    • classification head with standard cross-entropy loss.
    • SupCon head with custom SelfSL loss (currently it uses the Barlow Twins loss).
  • At inference, the SupCon head is discarded, hence incurring no overhead at runtime.

The recipes include:

  • a data pipeline using TwoCrop transform (to generate two views of an image for the SelfSL head)
  • a SupConClassifier (in charge of handling the two views of images)
  • a SupConClsHead (the one that uses the dual-head approach)
  • a SelfSL loss (the Barlow Twins loss)

So far, this method will be used in OTX when specifying the TrainType as SUPERVISEDCONTRASTIVE.

@arrufat arrufat added the otx mpa otx branch changes label Dec 8, 2022
Copy link
Copy Markdown
Contributor

@jaegukhyun jaegukhyun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Genreally, LGTM. I left one comment

Copy link
Copy Markdown
Contributor

@jaegukhyun jaegukhyun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left one comment, and I have a question. Where is the part for dividing learning rate by 2? I heard that is necessary because of changes in batch size

Also rename the linear member to fc and fc_feats to cls_score for
better alignment with the rest of the code.
@arrufat
Copy link
Copy Markdown
Author

arrufat commented Dec 13, 2022

I left one comment, and I have a question. Where is the part for dividing learning rate by 2? I heard that is necessary because of changes in batch size

As discussed with Wonju, for now, this logic is not implemented, we thought it would be better to do it manually and, once it because the default method for small datasets, add the logic in the code. But it's up for discussion.

Copy link
Copy Markdown
Contributor

@jaegukhyun jaegukhyun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, @harimkang, @supersoob, @JihwanEom anyone, could you check this PR once?

Copy link
Copy Markdown
Contributor

@harimkang harimkang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this works well, there seems to be no structural problem. LGTM.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

otx mpa otx branch changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants