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