Giter VIP home page Giter VIP logo

Comments (2)

github-actions avatar github-actions commented on June 2, 2024

Hi! thanks for your contribution!, great first issue!

from torchmetrics.

SkafteNicki avatar SkafteNicki commented on June 2, 2024

Hi @gui-miotto, thanks for raising this issue.
In general we do not make any guarantees regarding metrics in torchmetrics what happens when .compute is called before .update (or forward). That the accuracy metric happens to just give a warning and return 0 is just arbitrary. One could make the argument that the accuracy metric should actually crash because the score is clearly undefined if no input have been seen. The same argument is true for average precision score.

Specifically, for average precision metric you can actually just set the thresholds argument and you will get a warning and returned value of zero:

print(MulticlassAveragePrecision(num_classes=3, thresholds=100).compute())  # prints tensor(0.)

why does this not crash? Because the default value of thresholds=None means that we are dynamically calculating the thresholds values based on input to the metric. No input to the metric no meaningful thresholds to compute. Does it then make sense to when thresholds=100 to return 0? Not really because, again all the calculations are undefined.

I therefore keep the stance that in general we cannot make sure that metrics where no input is provided can actually succeed with the calculation, which is exactly what the warning we are giving to the user before the program crashes indicates.

from torchmetrics.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.