Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Special value 'latest' to evaluate latest available checkpoint #12

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions evaluate_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@
"evaluate_single_checkpoint",
"",
"If set, defines the checkpoint file prefix to evaluate "
'and then exit, e.g. "model.ckpt-97231".',
'and then exit, e.g. "model.ckpt-97231". Use "latest" to evaluate '
"the latest checkpoint.",
)

FLAGS = flags.FLAGS
Expand Down Expand Up @@ -146,7 +147,14 @@ def evaluate(hps, result_dir, tuner=None, trial_name=None):
)

if FLAGS.evaluate_single_checkpoint:
meta_file = FLAGS.evaluate_single_checkpoint + ".meta"
if FLAGS.evaluate_single_checkpoint == "latest":
latest_ckpt = tf.train.latest_checkpoint(result_dir)
if not latest_ckpt:
logging.warning("No checkpoints in %s", result_dir)
return
meta_file = os.path.basename(latest_ckpt) + ".meta"
else:
meta_file = FLAGS.evaluate_single_checkpoint + ".meta"
else:

potential_files = tf.gfile.ListDirectory(result_dir)
Expand Down