mecarill / classawareteacher

9 stars 4 forks source link

Cross_entropy calculation error #3

Open Shichang-Fu opened 4 months ago

Shichang-Fu commented 4 months ago

I encountered a problem in calculating the cross entropy loss_cls when reproducing the code: ` Expected object of scalar type Long but got scalar type Float for argument #2 ‘target`` My solution:

Add in cat/modeling/roi_heads/fast_rcnn.py547 line: gt_oht_classes = torch.argmax(gt_oht_classes, dim=1)

`gt_oht_classes = torch.argmax(gt_oht_classes, dim=1) losses = {

"loss_cls": cross_entropy(scores, gt_classes, reduction="mean"),

        "loss_cls": torch.mean(cross_entropy(scores, gt_oht_classes, reduction="none")*w), #cross_entropy(scores, gt_oht_classes, reduction="mean"),
        "loss_box_reg": self.box_reg_loss(
            proposal_boxes, gt_boxes, proposal_deltas, gt_classes, box_losses_w
        ),
    }
    return {k: v * self.loss_weight.get(k, 1.0) for k, v in losses.items()}`
slcheng97 commented 3 months ago

@henrenzhenhenrenzhenderen @mecarill I am curious about how long does it usually take to complete the training under the Cityscapes→FoggyCityscapes setting? While attempting to execute the traning command, I observed that it took around 2 days to run on 4 NVIDIA RTX 3090s. Are you in the same situation as me?

Shichang-Fu commented 3 months ago

@henrenzhenhenrenzhenderen @mecarill I am curious about how long does it usually take to complete the training under the Cityscapes→FoggyCityscapes setting? While attempting to execute the traning command, I observed that it took around 2 days to run on 4 NVIDIA RTX 3090s. Are you in the same situation as me?

I did not train Cityscapes→FoggyCityscapes, but other non-benchmark datasets