Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve metrics docs: 2 types of API #1540

Closed
vfdev-5 opened this issue Jan 1, 2021 · 5 comments 路 Fixed by #1554
Closed

Improve metrics docs: 2 types of API #1540

vfdev-5 opened this issue Jan 1, 2021 · 5 comments 路 Fixed by #1554

Comments

@vfdev-5
Copy link
Collaborator

vfdev-5 commented Jan 1, 2021

馃殌 Feature

Following #1538 it would be nice to explicitly mention here that there are 2 types of API :

  • using metric with Engine
  • using metric's reset/update/compute

and give examples.

@vfdev-5 vfdev-5 added this to To do in 0.5.1 via automation Jan 1, 2021
@ydcjeff
Copy link
Contributor

ydcjeff commented Jan 7, 2021

@vfdev-5 I am familiar with .attach() method. For reset/update/compute, the correct way is like this (computing epoch-wise)?

precision = Precision()
precision.attach(engine, 'precision')
@engine.on(Events.EPOCH_STARTED)
def reset():
    precision.reset()

def process_fn(e, b):
    ...
    precision.update((pred, target))

@engine.on(Events.EPOCH_COMPLETED)
def compute():
    precision.compute()

@sdesrozis
Copy link
Contributor

sdesrozis commented Jan 7, 2021

We have introduced MetricUsage to do this. See

class EpochWise(MetricUsage):

The doc is here : https://pytorch.org/ignite/metrics.html#metrics-and-its-usages

The relevant PR is #979

HTH

@vfdev-5
Copy link
Collaborator Author

vfdev-5 commented Jan 7, 2021

@ydcjeff yes, the idea is to show how to use reset/update/compute API without relation to the engine:

precision = Precision()

precision.update((pred1, target1))
precision.update((pred2, target2))
precision.update((pred3, target3))

print("Precision: ", precision.compute())

precision.reset()
precision.update((pred1, target1))
precision.update((pred2, target2))
precision.update((pred3, target3))
print("Precision: ", precision.compute())

@vfdev-5
Copy link
Collaborator Author

vfdev-5 commented Jan 13, 2021

@ydcjeff would you like to send a PR to fix this issue ?

@ydcjeff
Copy link
Contributor

ydcjeff commented Jan 13, 2021

I can only send in next weeks

vfdev-5 added a commit to vfdev-5/ignite that referenced this issue Jan 13, 2021
@vfdev-5 vfdev-5 mentioned this issue Jan 13, 2021
3 tasks
vfdev-5 added a commit to vfdev-5/ignite that referenced this issue Jan 13, 2021
0.5.1 automation moved this from To do to Done Jan 13, 2021
vfdev-5 added a commit that referenced this issue Jan 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
0.5.1
  
Done
Development

Successfully merging a pull request may close this issue.

3 participants