From c054751b9677c6b415ff2757d83518e9527b7781 Mon Sep 17 00:00:00 2001 From: steffen Date: Tue, 3 Mar 2020 22:02:24 +0100 Subject: [PATCH] logging active and clean --- .idea/deployment.xml | 11 ++--------- .idea/hom_traj_gen.iml | 2 +- .idea/misc.xml | 2 +- lib/utils/logging.py | 16 +++++++--------- main.py | 4 ++-- main_post.py | 0 6 files changed, 13 insertions(+), 22 deletions(-) create mode 100644 main_post.py diff --git a/.idea/deployment.xml b/.idea/deployment.xml index 83f58c5..b9d4963 100644 --- a/.idea/deployment.xml +++ b/.idea/deployment.xml @@ -1,15 +1,8 @@ - + - - - - - - - - + diff --git a/.idea/hom_traj_gen.iml b/.idea/hom_traj_gen.iml index 4b1d9c2..241d6f7 100644 --- a/.idea/hom_traj_gen.iml +++ b/.idea/hom_traj_gen.iml @@ -2,7 +2,7 @@ - + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index f164374..06cb946 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -3,5 +3,5 @@ - + \ No newline at end of file diff --git a/lib/utils/logging.py b/lib/utils/logging.py index b7032c0..966503d 100644 --- a/lib/utils/logging.py +++ b/lib/utils/logging.py @@ -18,9 +18,7 @@ class Logger(LightningLoggerBase): @property def log_dir(self): - if self.debug: - return Path(self.outpath) - return Path(self.experiment.log_dir).parent + return Path(self.testtubelogger.experiment.get_logdir()).parent @property def name(self): @@ -32,14 +30,14 @@ class Logger(LightningLoggerBase): @property def version(self): - return f"version_{self.config.get('main', 'seed')}" + return self.config.get('main', 'seed') @property def outpath(self): # ToDo: Add further path modification such as dataset config etc. return Path(self.config.train.outpath) - def __init__(self, config: Config, debug=False): + def __init__(self, config: Config): """ params (dict|None): Optional. Parameters of the experiment. After experiment creation params are read-only. Parameters are displayed in the experiment’s Parameters section and each key-value pair can be @@ -53,8 +51,8 @@ class Logger(LightningLoggerBase): """ super(Logger, self).__init__() - self.debug = debug self.config = config + self.debug = self.config.main.debug self._testtube_kwargs = dict(save_dir=self.outpath, version=self.version, name=self.name) self._neptune_kwargs = dict(offline_mode=self.debug, api_key=self.config.project.neptune_key, @@ -68,9 +66,9 @@ class Logger(LightningLoggerBase): self.testtubelogger.log_hyperparams(params) pass - def log_metrics(self, metrics, step_num): - self.neptunelogger.log_metrics(metrics, step_num) - self.testtubelogger.log_metrics(metrics, step_num) + def log_metrics(self, metrics, step=None): + self.neptunelogger.log_metrics(metrics, step=step) + self.testtubelogger.log_metrics(metrics, step=step) pass def log_config_as_ini(self): diff --git a/main.py b/main.py index d64b765..52f31a8 100644 --- a/main.py +++ b/main.py @@ -66,7 +66,7 @@ config = Config.read_namespace(args) # Logger # ============================================================================= -logger = Logger(config, debug=True) +logger = Logger(config) # Checkpoint Callback # ============================================================================= @@ -95,7 +95,7 @@ if __name__ == "__main__": log_save_interval=model.data_len // 10, # TODO: Better Value / Setting checkpoint_callback=checkpoint_callback, logger=logger, - fast_dev_run=config.get('main', 'debug'), + fast_dev_run=config.main.debug, early_stop_callback=None ) diff --git a/main_post.py b/main_post.py new file mode 100644 index 0000000..e69de29