-
Notifications
You must be signed in to change notification settings - Fork 0
/
log.py
35 lines (25 loc) · 717 Bytes
/
log.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from tensorboard_logger import configure, log_value
class BaseLogger(object):
def __init__(self):
pass
def log(tag,val,step):
pass
class TensorBoardLogger(BaseLogger):
def __init__(self, fname):
super(TensorBoardLogger, self).__init__()
configure(fname, flush_secs=5)
def log(tag,val,step):
log_value(tag,val,step)
class SacredLogger(BaseLogger):
def __init__(self, run):
super(SacredLogger, self).__init__()
self._run = run
def log(tag,val,step):
self._run.log_scalar(tag,val,step)
class ComposedLogger(BaseLogger):
def __init__(self, loggers):
super(ComposedLogger, self).__init__()
self.loggers = loggers
def log(tag,val,step):
for l in self.logger:
l.log(tag,val,step)