Commit 6cce6e01 authored by JimCai91's avatar JimCai91 Committed by Yuxin Wu

update MinSaver function in saver.py (#212)

* update MinSaver function in saver.py

* fix linting and style
parent a6745419
......@@ -5,6 +5,7 @@
import tensorflow as tf
import os
import shutil
import glob
from .base import Callback
from ..utils import logger
......@@ -122,10 +123,14 @@ class MinSaver(Callback):
raise RuntimeError(
"Cannot find a checkpoint state. Do you forget to use ModelSaver?")
path = ckpt.model_checkpoint_path
newname = os.path.join(logger.LOG_DIR,
self.filename or
('max-' if self.reverse else 'min-' + self.monitor_stat + '.tfmodel'))
shutil.copy(path, newname)
('max-' if self.reverse else 'min-' + self.monitor_stat))
files_to_copy = glob.glob(path + '*')
for file_to_copy in files_to_copy:
shutil.copy(file_to_copy, file_to_copy.replace(path, newname))
#shutil.copy(path, newname)
logger.info("Model with {} '{}' saved.".format(
'maximum' if self.reverse else 'minimum', self.monitor_stat))
......
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