Monitoring#
- class kornia.metrics.AverageMeter[source]#
Computes and stores the average and current value.
- Convention:
update(val, n)addsval * ntosumandntocount, soavgis then-weighted mean: the mean over samples when everyvalis a batch mean andnits batch size.valkeeps the last value passed, unweighted.Values are not rescaled:
accuracy()percentages average to a percentage. A tensorvalkeepssuma tensor that holds its autograd graph; pass a detached tensor or a Python number to avoid keeping it.
Example
>>> stats = AverageMeter() >>> acc1 = torch.tensor(99.0) # top-1 accuracy of a batch in percent, as in K.metrics.accuracy(...)[0] >>> stats.update(acc1, n=1) # where n is batch size usually >>> round(stats.avg, 2) 99.0