Commit 477e1590 authored by Ilya Ovodov's avatar Ilya Ovodov

TensorBoardLogger.start_server only print command. Fix LogTrainingResults always…

TensorBoardLogger.start_server only print command. Fix LogTrainingResults always run 1st time (to provide statistics)
parent bb058a43
...@@ -138,7 +138,7 @@ class LogTrainingResults: ...@@ -138,7 +138,7 @@ class LogTrainingResults:
duty_cycles = self.duty_cycles duty_cycles = self.duty_cycles
elif isinstance(self.duty_cycles, dict): elif isinstance(self.duty_cycles, dict):
duty_cycles = self.duty_cycles[event] duty_cycles = self.duty_cycles[event]
if self.calls_count[event] % duty_cycles != 0: if self.calls_count[event] % duty_cycles != 0 and self.calls_count[event] != 1: #always run 1st time to provide statistics
return return
for key,loader in self.loaders_dict.items(): for key,loader in self.loaders_dict.items():
self.evaluator.run(loader) self.evaluator.run(loader)
...@@ -172,13 +172,14 @@ class TensorBoardLogger: ...@@ -172,13 +172,14 @@ class TensorBoardLogger:
self.call_count = 0 self.call_count = 0
trainer_engine.add_event_handler(Events.COMPLETED, self.on_completed) trainer_engine.add_event_handler(Events.COMPLETED, self.on_completed)
def start_server(self, port): def start_server(self, port, start_it = False):
#cmd = r"tensorboard --host 127.0.0.1 --port {port} --logdir {dir}".format(port=port, dir=self.log_dir) #cmd = r"tensorboard --host 127.0.0.1 --port {port} --logdir {dir}".format(port=port, dir=self.log_dir)
#print(cmd) #print(cmd)
#os.popen(cmd) #os.popen(cmd)
cmd = r'tensorboard --host 127.0.0.1 --port {port} --logdir ""'.format(port=port).split(' ') cmd = r'tensorboard --host 127.0.0.1 --port {port} --logdir ""'.format(port=port).split(' ')
cmd[-1] = self.log_dir # can contain spaces cmd[-1] = self.log_dir # can contain spaces
print(' '.join(cmd)) print(' '.join(cmd))
if start_it:
subprocess.Popen(cmd) subprocess.Popen(cmd)
def on_completed(self, engine): def on_completed(self, engine):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment