jxgu1016/MNIST_center_loss_pytorch

a tiny cleanup for `scatter_add_()`

Closed this issue · 1 comments

Since you're doing in-place operation at line 42 of Centerloss.py. You don't need to re-assign it. So just:

counts.scatter_add_(0, label.long(), ones)

That's right that scatter_add_ is a in-place op but it also returns the tensor. At line 42 & 43, I use the two styles to show the difference. Anyway, thanks for pointing this out.