forked from utopia-group/ReCoeus
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathevent_logger.py
More file actions
33 lines (24 loc) · 875 Bytes
/
event_logger.py
File metadata and controls
33 lines (24 loc) · 875 Bytes
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
import logging
from tensorboardX import SummaryWriter
class EventLogger:
def __init__(self, root_dir):
self.root_dir = root_dir
if root_dir is None:
self.tensorboard_logger = None
else:
root_dir.mkdir(parents=True, exist_ok=False)
self.tensorboard_logger = SummaryWriter(str(root_dir))
self.console = logging.getLogger(__name__)
def log_scalar(self, tag, value, iteration):
if self.tensorboard_logger is not None:
self.tensorboard_logger.add_scalar(tag, value, iteration)
def debug(self, msg):
self.console.debug(msg)
def info(self, msg):
self.console.info(msg)
def warning(self, msg):
self.console.warning(msg)
def error(self, msg):
self.console.error(msg)
def critical(self, msg):
self.console.critical(msg)