question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Queries on Weights for Classification Loss on Background Boxes

See original GitHub issue

Hi,

First of all congratulations for the great work and many thanks for sharing the code !!

I have been checking out the code, and have a query regarding the weight for classification loss on background proposals.

The classification loss on pseudo labels seems to be done here https://github.com/microsoft/SoftTeacher/blob/bef9a256e5c920723280146fc66b82629b3ee9d4/ssod/models/soft_teacher.py#L240

where the bbox_targets are computed a couple of lines earlier here https://github.com/microsoft/SoftTeacher/blob/bef9a256e5c920723280146fc66b82629b3ee9d4/ssod/models/soft_teacher.py#L215

which I understand refers to the bbox_head.py in mmdetection here https://github.com/open-mmlab/mmdetection/blob/bde7b4b7eea9dd6ee91a486c6996b2d68662366d/mmdet/models/roi_heads/bbox_heads/bbox_head.py#L183

which further calls _get_target_single() here https://github.com/open-mmlab/mmdetection/blob/bde7b4b7eea9dd6ee91a486c6996b2d68662366d/mmdet/models/roi_heads/bbox_heads/bbox_head.py#L117

But in this, the negative proposals are assigned weight of 1.0, which should have been cls_score for the proposals after running them through the Teacher, as mentioned in the paper.

Maybe I am missing something in the code. It would be really great if you could kindly clarify the above query or point me to where it uses the cls-score from the teacher into the classification loss for background proposals.

Thank You !!

Best Regards, Anuj

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
lliuzcommented, Jan 14, 2022

@anuj-sharma-19 @Jack-Hu-2001 The correct equation, as I understand it, is: image @MendelXu please check it.

1reaction
anuj-sharma-19commented, Jan 7, 2022

In the final classification loss here https://github.com/microsoft/SoftTeacher/blob/bef9a256e5c920723280146fc66b82629b3ee9d4/ssod/models/soft_teacher.py#L243

it seems loss is:

# where `w` is the cls-score from teacher for background proposal
total_cls_loss = sum(cls_loss_on_all_fg_proposals) + sum(w * cls_loss_on_bg_proposals)
avg_factor = N_fg + sum(w's on bg proposals)
loss_cls = total_cls_loss / avg_factor

So, avg_factor is not as N_fg in the paper. Also, the w_j as used in the paper (Eq 5) does not seem to be used in the code.

It would be really great if you could you please clarify these couple of doubts.

Thank You !!

Anuj

Read more comments on GitHub >

github_iconTop Results From Across the Web

Understanding Focal Loss in 5 mins | Medium | VisionWizard
The focal loss gives less weight to easy examples and gives more ... are False negatives(Predicted as background, query box is foreground).
Read more >
deep learning - class weights formula for imbalanced dataset
we should consider distribution as a useful feature of dataset. so I think the weighted loss would have better performance in most cases....
Read more >
Multi-label classification with class weights in Keras
For the multi-label classification, I am using 'binary-cross entropy' as cost function and 'sigmoid' as the activation function. When I tried ...
Read more >
Focal Loss in Object Detection - Analytics Vidhya
In this article we explain Focal Loss which is an improved version of Cross-Entropy Loss, that tries to handle the class imbalance problem....
Read more >
DETR - Hugging Face
Given a fixed small set of learned object queries, DETR reasons about the relations of the ... (cross-entropy) for class prediction and a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found