Hello Johnson!



 coolsuntraveler:

However, it seems “mean” is divided by the sum of the weights of each element, not number of elements in the output. Am I misunderstanding the documentation or the documentation is inaccurate?


You are correct that in the weighted case, “mean” is calculated by
dividing by the sum of the weights.  (In other words, a weighted
average is being calculated.)
The documentation on this is arguably inaccurate, or at least rather
unclear.
Anyway, the way I think of it, if I have ten samples, all with the same
loss, say, 1.23, I would like my “mean” loss, weighted or not, to be
this same loss value, 1.23.  So dividing by the sum of the weights is,
for me, the “expected behavior,” even if the documentation says
otherwise.
(This issue has come up before on the forum, although I don’t have
any references at hand.)
Best.
K. Frank