Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

accuracy function only gives zero-output and breaks for new numpy version #318

Open
pbouss opened this issue Nov 17, 2023 · 0 comments
Open

Comments

@pbouss
Copy link

pbouss commented Nov 17, 2023

The accuracy function in metrics.py does not work properly.

def accuracy(y_pred: Tensor, y_true: Tensor, **kwargs):
y_pred = y_pred.cpu()
outputs = np.argmax(y_pred, axis=1)
return np.mean(outputs.numpy() == y_true.detach().cpu().numpy())

This is due to outputs having less axes than y_true. In the newest numpy 1.26 this raises in error. In older numpy versions this gives an DeprecationWarning and outputs False, due to the mean it becomes 0. Therefore this functions outputs constantly zero.
Possibly it could be adapted easily.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant