Git Product home page Git Product logo

Comments (11)

jspaezp avatar jspaezp commented on July 26, 2024 2

Hello @SkafteNicki I like the idea of your implementation and I think it could add as well an optional argument to the clone method.

I am thinking something like ...

...
def clone(self, prefix = None):
    cloned = super().clone()
    if prefix is not None:
        cloned.prefix = prefix
    return cloned
...

Since it would make it a lot easier to make clones of large collections (train and test metrics for instance ...)
let me know when you feel would be a good time to work on it (although i feel like you got it covered, thanks a lot)

from torchmetrics.

SkafteNicki avatar SkafteNicki commented on July 26, 2024 2

@jspaezp please checkout the PR I have opened #70 to see if anything is missing :]

from torchmetrics.

carmocca avatar carmocca commented on July 26, 2024 1

Fix the documentation. Does MetricCollection have a mechanism to set a prefix? If it doesn't, then the argument should be added there

from torchmetrics.

SkafteNicki avatar SkafteNicki commented on July 26, 2024

@carmocca are you in favor of adding the argument to log_dict or fix the documentation?

from torchmetrics.

jspaezp avatar jspaezp commented on July 26, 2024

@carmocca I agree this would be a nice addition and the implementation seems easy ...

-def __init__(self, metrics: Union[List[Metric], Tuple[Metric], Dict[str, Metric]]):
+def __init__(self, metrics: Union[List[Metric], Tuple[Metric], Dict[str, Metric]], prefix: Union[Literal[None],str]=None):
         super().__init__()
         if isinstance(metrics, dict):
+            prefix = prefix if prefix is not None else ""
             # Check all values are metrics
             for name, metric in metrics.items():
                 if not isinstance(metric, Metric):
                     raise ValueError(
                         f"Value {metric} belonging to key {name}"
                         " is not an instance of `pl.metrics.Metric`"
                     )
-                self[name] = metric
+                self[prefix + name] = metric

possibly add a warning as well if a list (and not a dict) is passed so you know that it will get ignored.
let me know if you want the PR. (I could also update the docs)

Kindest wishes,
Sebastian

from torchmetrics.

SkafteNicki avatar SkafteNicki commented on July 26, 2024

@jspaezp your solution looks very similar to the one I had in mind:
Lightning-AI/pytorch-lightning@master...SkafteNicki:fix_prefix_arg
Feel free to submit a PR but please wait a couple of days for an update that will come to the metrics package (cannot disclose exactly what right now) :]

from torchmetrics.

uwaisiqbal avatar uwaisiqbal commented on July 26, 2024

I'm just updating to the latest version of pytorch lightning and I ran into this issue also. Do we have an ETA for when it will be released?

from torchmetrics.

github-actions avatar github-actions commented on July 26, 2024

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

from torchmetrics.

jspaezp avatar jspaezp commented on July 26, 2024

@SkafteNicki looks great! Amazing work!

@uwaisiqbal (just mentioning you so you know it is getting merged)

from torchmetrics.

uwaisiqbal avatar uwaisiqbal commented on July 26, 2024

Awesome thanks for the update and for the amazing work!

from torchmetrics.

uwaisiqbal avatar uwaisiqbal commented on July 26, 2024

When is the update with the prefix arg going to be released? Also, the documentation for the MetricCollections is out of date where it mentions the prefix arg can be used when cloning the MetricCollection https://torchmetrics.readthedocs.io/en/latest/pages/overview.html#metriccollection

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.