(model_dir)
return checkpoint_id
Get the best checkpoint in a dir a coording to average rouge scores.
Get the best checkpoint in a dir a coording to average rouge scores.
Get the best checkpoint in a dir a coording to average rouge scores .
def _get_best_checkpoint_id(model_dir):
  """Get the best checkpoint in a dir a coording to average rouge scores."""
  filenames = tf.io.gfile.glob(
      os.path.join(model_dir, FLAGS.text_metrics_pattern))
  if not filenames:
    raise ValueError("Can not find text_metrics.")
  max_score = -float("inf")
  j = -1
  for i, filename in enumerate(filenames):
    d = _extract_text_metrics(filename)
    sum_score = d["rouge1-F"][0] + 2 * d["rouge2-F"][0] + d["rougeL-F"][0]
    if sum_score > max_score:
      max_score = sum_score
      j = i
  checkpoint_id = int(os.path.basename(filenames[j]).split("-")[1])
  return checkpoint_id
def _get_best_checkpoint_id ( model_dir ) : filenames = tf . io . gfile . glob ( os . path . join ( model_dir , FLAGS . text_metrics_pattern ) ) if not filenames : raise ValueError ( "Can not find text_metrics." ) max_score = - float ( "inf" ) j = - 1 for i , filename in enumerate ( filenames ) : d = _extract_text_metrics ( filename ) sum_score = d [ "rouge1-F" ] [ 0 ] + 2 * d [ "rouge2-F" ] [ 0 ] + d [ "rougeL-F" ] [ 0 ] if sum_score > max_score : max_score = sum_score j = i checkpoint_id = int ( os . path . basename ( filenames [ j ] ) . split ( "-" ) [ 1 ] ) return checkpoint_id