Commit bb058a43 authored by IlyaOvodov's avatar IlyaOvodov

upd params.save (create dirs), log (log.log)

parent 52cc9096
...@@ -125,7 +125,7 @@ class LogTrainingResults: ...@@ -125,7 +125,7 @@ class LogTrainingResults:
self.best_model_buffer = best_model_buffer self.best_model_buffer = best_model_buffer
self.params = params self.params = params
if filename is None: if filename is None:
filename = self.params.get_model_name() + ".log" filename = "log.log"
self.file_name = os.path.join(self.params.get_base_filename(), rel_dir, filename) self.file_name = os.path.join(self.params.get_base_filename(), rel_dir, filename)
self.calls_count = collections.defaultdict(int) self.calls_count = collections.defaultdict(int)
......
...@@ -71,7 +71,7 @@ class AttrDict(dict): ...@@ -71,7 +71,7 @@ class AttrDict(dict):
assert self.has('data_root') assert self.has('data_root')
return os.path.join(self.data_root, self.get_model_name()) return os.path.join(self.data_root, self.get_model_name())
def save(self, base_fn = None, verbose = 1, can_overwrite = False): def save(self, base_fn = None, verbose = 1, can_overwrite = False, create_dirs = False):
''' '''
save to file adding '.param.txt' to name save to file adding '.param.txt' to name
''' '''
...@@ -80,6 +80,9 @@ class AttrDict(dict): ...@@ -80,6 +80,9 @@ class AttrDict(dict):
params_fn = base_fn + '.param.txt' params_fn = base_fn + '.param.txt'
if not can_overwrite: if not can_overwrite:
assert not os.path.exists(params_fn), "Can't save parameters to {}: File exists".format(params_fn) assert not os.path.exists(params_fn), "Can't save parameters to {}: File exists".format(params_fn)
if create_dirs:
dir_name = os.path.dirname(params_fn)
os.makedirs(dir_name, exist_ok=True)
with open(params_fn, 'w+') as f: with open(params_fn, 'w+') as f:
s = repr(self) s = repr(self)
s = s + '\nhash: ' + self.hash() s = s + '\nhash: ' + self.hash()
......
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