huggingface / evaluate

🤗 Evaluate: A library for easily evaluating machine learning models and datasets.
https://huggingface.co/docs/evaluate
Apache License 2.0
1.99k stars 255 forks source link

MSE not accepting (n_samples, n_ouptuts) despite docs stating so #550

Open bauersimon opened 7 months ago

bauersimon commented 7 months ago

The evaluation card for MSE states:


Mandatory inputs:


So it should be usable similar to pytorch's MSELoss with multiple dimensions. But using it with (batch_size, multiple_outputs) doesn't work:

import evaluate
import numpy as np

m = evaluate.load('mse')
print(m.compute(predictions=np.random.rand(16,2), references=np.random.rand(16,2)))

⬇️

ValueError: Predictions and/or references don't match the expected format.
Expected format: {'predictions': Value(dtype='float32', id=None), 'references': Value(dtype='float32', id=None)},
Input predictions: ...
Input references: ...

Version: evaluate==0.4.1

shenxiangzhuang commented 5 months ago

Hi @bauersimon , the quick answer for your question is:

import evaluate
import numpy as np

- m = evaluate.load('mse')
+ m = evaluate.load('mse', 'multilist')
print(m.compute(predictions=np.random.rand(16,2), references=np.random.rand(16,2)))

And, the error message is also too vague to address the problem.

bauersimon commented 5 months ago

Thanks! Should probably be mentioned in the docs then 😅.