michuanhaohao / reid-strong-baseline

Bag of Tricks and A Strong Baseline for Deep Person Re-identification
http://openaccess.thecvf.com/content_CVPRW_2019/papers/TRMTMCT/Luo_Bag_of_Tricks_and_a_Strong_Baseline_for_Deep_Person_CVPRW_2019_paper.pdf
MIT License
2.27k stars 577 forks source link

CrossEntropyLoss reduction write error #205

Open AutumnZ-94 opened 3 years ago

AutumnZ-94 commented 3 years ago

should

loss = (- targets * log_probs).mean(0).sum() in https://github.com/michuanhaohao/reid-strong-baseline/blob/master/layers/triplet_loss.py#L146

be supposed to loss = (- targets * log_probs).sum(1).mean()?

SuperbTUM commented 1 year ago

@AutumnZ-94 Try this. They should be the same

x = torch.randn(32, 64)

y1 = x.mean(0).sum()
y2 = x.sum(1).mean()

assert torch.allclose(y1, y2)