pytorch-lightning icon indicating copy to clipboard operation
pytorch-lightning copied to clipboard

F beta with macro computation outputs nans for certain inputs

Open gabhinav001 opened this issue 6 years ago • 1 comments

🐛 Bug

Please reproduce using the BoringModel and post here

https://colab.research.google.com/drive/1108mj1bKob0QpGlq2Q09L7ulmPDE49D1?usp=sharing

To Reproduce

p = torch.Tensor([[0,0],[0,1]])
t = torch.Tensor([[0,1],[1,0]])
f_beta = Fbeta(num_classes=len(t[0]), average='macro', multilabel=True)
f_beta(p, t)

> tensor(nan)

Expected behavior

tensor(0)

Environment

Please copy and paste the output from our environment collection script (or fill out the checklist below manually).

You can get the script and run it with:

wget https://raw.githubusercontent.com/PyTorchLightning/pytorch-lightning/master/tests/collect_env_details.py
# For security purposes, please check the contents of collect_env_details.py before running it.
python collect_env_details.py
  • PyTorch Lightning Version: 1.0.1
  • PyTorch Version (e.g., 1.0):
  • OS (e.g., Linux):
  • How you installed PyTorch (conda, pip, source):
  • Build command you used (if compiling from source):
  • Python version:
  • CUDA/cuDNN version:
  • GPU models and configuration:
  • Any other relevant information:

Additional context

gabhinav001 avatar Oct 16 '20 06:10 gabhinav001

Fixed the issue with https://github.com/PyTorchLightning/pytorch-lightning/pull/4183

gabhinav001 avatar Oct 16 '20 06:10 gabhinav001