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
Issue 874 : add custom events for Metrics #979
Conversation
@vfdev-5 thoughts on this draft ? |
We may have to take this comment into account for the usage : #644 (comment) |
Same issue?? |
Major refactoring
The idea is to have engine1 = ...
engine2 = ...
m = MyMetric()
# current API
m.attach(engine1, "m")
m.attach(engine2, "m", usage=BatchWise())
# possible API
attach(metric=m, engine=engine1, name="m")
attach(metric=m, engine=engine2, name="m", usage=BatchWise()) Thoughts ? |
@sdesrozis please, show an example of usage. For instance, I do not understand the need of another interface... Thanks |
The idea is to have This is a separation of concerns. However, this is just a draft :) The interface |
@sdesrozis I'm not fan of "possible API", let's keep current API. |
Yes, I can remove it, no problem 😊 |
Removed |
@sdesrozis thanks ! What do you think about to enhance the following API by engine1 = ...
engine2 = ...
m = MyMetric()
# current API
m.attach(engine1, "m")
m.attach(engine2, "m", usage="batch_wise") # ~ BatchWise()
m.attach(engine2, "m", usage="epoch_wise") # ~ EpochWise() ? No need to import those classes. |
@sdesrozis code looks OK, documentation layout is not correct:
|
ignite/metrics/metric.py
Outdated
""" | ||
Attaches current metric to provided engine. On the end of engine's run, | ||
`engine.state.metrics` dictionary will contain computed metric's value under provided name. | ||
|
||
Args: | ||
engine (Engine): the engine to which the metric must be attached | ||
name (str): the name of the metric to attach | ||
usage (str or MetricUsage, optional): the usage of the metric. Valid string values should be | ||
'epoch_wise' (default) or 'batch_wise'. |
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.
Missing indent here
ignite/metrics/metric.py
Outdated
@@ -182,6 +293,8 @@ def detach(self, engine: Engine) -> None: | |||
|
|||
Args: | |||
engine (Engine): the engine from which the metric must be detached | |||
usage (str or MetricUsage, optional): the usage of the metric. Valid string values should be | |||
'epoch_wise' (default) or 'batch_wise'. |
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.
Missing indent here
@vfdev-5 thank you, I update soon :p |
Doc done. Next, I would like to refactor a last thing after merge of fix for #1004 (if ok). |
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.
Looks good !
Fixes #874
Description:
Allow customization for
Events
ofMetrics
.Check list: