Following https://github.com/pytorch/ignite/issues/1538 it would be nice to explicitly mention here that there are 2 types of API :
and give examples.
@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()
We have introduced MetricUsage to do this. See https://github.com/pytorch/ignite/blob/5ceacbb3ccea433317df2776556bd4a08d0a923d/ignite/metrics/metric.py#L52
The doc is here : https://pytorch.org/ignite/metrics.html#metrics-and-its-usages
The relevant PR is #979
HTH
@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())
@ydcjeff would you like to send a PR to fix this issue ?
I can only send in next weeks