forked from qqueing/DeepSpeaker-pytorch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogger.py
27 lines (22 loc) · 774 Bytes
/
logger.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
import os
from tensorboard_logger import configure, log_value
class Logger(object):
def __init__(self, log_dir):
# clean previous logged data under the same directory name
self._remove(log_dir)
# configure the project
configure(log_dir)
self.global_step = 0
def log_value(self, name, value):
log_value(name, value, self.global_step)
return self
def step(self):
self.global_step += 1
@staticmethod
def _remove(path):
""" param <path> could either be relative or absolute. """
if os.path.isfile(path):
os.remove(path) # remove the file
elif os.path.isdir(path):
import shutil
shutil.rmtree(path) # remove dir and all contains