A confusion on evaluation metrics


#1
mse = mx.metric.create('mse')
x = mx.nd.array([1,2,3,4]) # 1D array
mse.update(x, x + 0.1)
print(mse.get()) # 0.01. OK
mse = mx.metric.create('mse')
x = mx.nd.array([[1,2,3,4]]) # 2D array
mse.update(x, x + 0.1)
print(mse.get()) # 2.509999 ... ??

At first I thought that when 2D arraies are given each row represents an output and the set of rows is treated as a batch. However, that seems not the case. What’s the second result 2.509999?


#2

Ok, I found that I had to give lists of 2D NDArrays to update.
Just NDArrays or lists of 1D NDArrays do not work.

mse = mx.metric.create('mse')
x = mx.nd.array([[1,2,3,4]]) # 2D array
mse.update([x], [x + 0.1]) # The arguments must be lists
print(mse.get()) # 0.01.

However, I think this is too errorprone. Some guards on the arguments types in the implementation of update method would be helpful.


#3

I opend an issue (#9865).