reid-strong-baseline icon indicating copy to clipboard operation
reid-strong-baseline copied to clipboard

CrossEntropyLoss reduction write error

Open AutumnZ-94 opened this issue 3 years ago • 1 comments

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()?

AutumnZ-94 avatar Aug 03 '21 06:08 AutumnZ-94

@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)

SuperbTUM avatar Aug 26 '23 22:08 SuperbTUM