Skip to content

Commit

Permalink
fix logging
Browse files Browse the repository at this point in the history
  • Loading branch information
ChenRocks committed Sep 1, 2020
1 parent 1b62840 commit feda6bb
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions utils/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
NOTE: loggers are global objects use with caution
"""
import logging
import math

import tensorboardX

Expand Down Expand Up @@ -74,14 +75,18 @@ def __init__(self, name, val=None, smooth=0.99):
self._val = val

def __call__(self, value):
self._val = (value if self._val is None
else value*(1-self._sm) + self._val*self._sm)
val = (value if self._val is None
else value*(1-self._sm) + self._val*self._sm)
if not math.isnan(val):
self._val = val

def __str__(self):
return f'{self._name}: {self._val:.4f}'

@property
def val(self):
if self._val is None:
return 0
return self._val

@property
Expand Down

0 comments on commit feda6bb

Please sign in to comment.