-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Add Base class for metrics #1293
Conversation
Codecov Report
@@ Coverage Diff @@
## metrics #1293 +/- ##
=======================================
- Coverage 92% 91% -1%
=======================================
Files 62 63 +1
Lines 3188 3230 +42
=======================================
+ Hits 2920 2936 +16
- Misses 268 294 +26 |
Hello @justusschock! Thanks for updating this PR. There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻 Comment last updated at 2020-03-31 13:33:44 UTC |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GREAT work, just a quick pass, need to read again... 🤖
class BaseMetric(torch.nn.Module, ABC): | ||
def __init__(self, name: str, | ||
reduce_group: Optional[Any] = torch.distributed.group.WORLD, | ||
reduce_op: Optional[Any] = torch.distributed.ReduceOp.SUM): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
inst mean more frequently used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mean is not available as a reduction op :)
https://pytorch.org/docs/stable/distributed.html#torch.distributed.ReduceOp
pytorch_lightning/metrics/metric.py
Outdated
metric value | ||
|
||
""" | ||
raise NotImplementedError |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for abstract no need for this raise
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know, but it doesn't matter if you put pass
or raise NotImplementedError
there and I found this to be more intuitive, but we can still change this, if you want...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this line won't be ever tested so lover test coverage count... lol
return elem_type([func(r) for r in result]) | ||
# not possible to reduce this type | ||
else: | ||
return result |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is not safe since all result
assignment is under some conditions...
rather instead each return do result assignment and always return result
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be safe, since we just return the input variable as is, if there is nothing to sync...
suggested changes Co-Authored-By: Jirka Borovec <[email protected]>
closed in favour of #1326 |
@justusschock what os the difference? |
@Borda the new version is cleaner and has more capabilities. This includes the changes, I had to make when implementing the scikit part. It was easier to make it as a separate or than to incorporate it into this PR |
Before submitting
What does this PR do?
Implements a base class for new metrics.
Fixes #1294
PR review
Anyone in the community is free to review the PR once the tests have passed.
If we didn't discuss your PR in Github issues there's a high chance it will not be merged.
Did you have fun?
Make sure you had fun coding 🙃
A review of the general interface would be nice, before I start to implement the necessary tests