auto-increment loss filenames to stop clobbering
This commit is contained in:
parent
e22316a4c9
commit
7878f94f43
1 changed files with 9 additions and 2 deletions
11
onn_mnist.py
11
onn_mnist.py
|
@ -70,7 +70,7 @@ else:
|
||||||
|
|
||||||
load_fn = None
|
load_fn = None
|
||||||
save_fn = 'mnist.h5'
|
save_fn = 'mnist.h5'
|
||||||
log_fn = 'mnist_losses.npz'
|
log_fn = 'floss{}.npz'
|
||||||
|
|
||||||
fn = 'mnist.npz'
|
fn = 'mnist.npz'
|
||||||
mnist_dim = 28
|
mnist_dim = 28
|
||||||
|
@ -253,9 +253,16 @@ if save_fn is not None:
|
||||||
model.save_weights(save_fn, overwrite=True)
|
model.save_weights(save_fn, overwrite=True)
|
||||||
|
|
||||||
if log_fn:
|
if log_fn:
|
||||||
log('saving losses', log_fn)
|
|
||||||
kwargs = dict()
|
kwargs = dict()
|
||||||
for k, v in logs.items():
|
for k, v in logs.items():
|
||||||
if len(v) > 0:
|
if len(v) > 0:
|
||||||
kwargs[k] = np.array(v, dtype=_f)
|
kwargs[k] = np.array(v, dtype=_f)
|
||||||
|
if '{}' in log_fn:
|
||||||
|
from os.path import exists
|
||||||
|
for i in range(10000):
|
||||||
|
candidate = log_fn.format(i)
|
||||||
|
if not exists(candidate):
|
||||||
|
log_fn = candidate
|
||||||
|
break
|
||||||
|
log('saving losses', log_fn)
|
||||||
np.savez_compressed(log_fn, **kwargs)
|
np.savez_compressed(log_fn, **kwargs)
|
||||||
|
|
Loading…
Reference in a new issue