Hi,
Thanks for the link, which I should have read when migrating…
I think you misread me, I’m not complaining about the fact that we can aggregate losses when they are all tensors (I suppose that would be the case in your examples). What I’m pointing at is the implicit “type-cast” happening on Python numbers. Particularly I find the combination of these two things very error prone:


float += ScalarTensor is valid and changes the type of the left value
formatting a zero-dimensional tensor only shows the scalar value, without any indication that the variable is indeed a tensor

The second point is easy to fix. As for the first, __radd__ (and its friends) could print a warning which would be easily silenced by an explicit cast using torch.tensor.