avg_metrics.py 471 字节
Newer Older
C
cuicheng01 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
from paddle import nn


class AvgMetrics(nn.Layer):
    def __init__(self):
        super().__init__()
        self.avg_meters = {}

    def reset(self):
        self.avg_meters = {}

    @property
    def avg(self):
        if self.avg_meters:
            for metric_key in self.avg_meters:
                return self.avg_meters[metric_key].avg

    @property
    def avg_info(self):
        return ", ".join([self.avg_meters[key].avg_info for key in self.avg_meters])