(model_dir, global_step, eval_tag, aggregates_dict,
                      length_histograms)
Writes text metrics to a file.
Writes text metrics to a file.
Writes text metrics to a file .
def _write_aggregates(model_dir, global_step, eval_tag, aggregates_dict,
                      length_histograms):
  """Writes text metrics to a file."""

  output_filename = os.path.join(
      model_dir, "text_metrics-{}-{}.txt".format(global_step, eval_tag))
  with tf.gfile.Open(output_filename, "w") as f:
    for k, v in sorted(aggregates_dict[_ROUGE_METRIC].items()):
      f.write("%s-R,%f,%f,%f\n" %
              (k, v.low.recall, v.mid.recall, v.high.recall))
      f.write("%s-P,%f,%f,%f\n" %
              (k, v.low.precision, v.mid.precision, v.high.precision))
      f.write("%s-F,%f,%f,%f\n" %
              (k, v.low.fmeasure, v.mid.fmeasure, v.high.fmeasure))
    for k, v in sorted(aggregates_dict[_BLEU_METRIC].items()):
      f.write("%s,%f,%f,%f\n" % (k, v.low.bleu, v.mid.bleu, v.high.bleu))
    for k, v in sorted(aggregates_dict[_REPETITION_METRIC].items()):
      f.write("%s-T-token,%f,%f,%f\n" %
              (k, v.low.target_ratio, v.mid.target_ratio, v.high.target_ratio))
      f.write("%s-P-token,%f,%f,%f\n" %
              (k, v.low.prediction_ratio, v.mid.prediction_ratio,
               v.high.prediction_ratio))
    for k, v in sorted(aggregates_dict[_LENGTH_METRIC].items()):
      f.write(
          "%s-T,%f,%f,%f\n" %
          (k, v.low.target_length, v.mid.target_length, v.high.target_length))
      f.write("%s-P,%f,%f,%f\n" %
              (k, v.low.prediction_length, v.mid.prediction_length,
               v.high.prediction_length))
      f.write("%s-R,%f,%f,%f\n" %
              (k, v.low.relative_length, v.mid.relative_length,
               v.high.relative_length))
    for k, histogram in sorted(length_histograms.items()):
      f.write("%s-hist-T,%s\n" % (k, str(histogram.target)))
      f.write("%s-hist-P,%s\n" % (k, str(histogram.prediction)))
      f.write("%s-hist-R,%s\n" % (k, str(histogram.relative)))
def _write_aggregates ( model_dir , global_step , eval_tag , aggregates_dict , length_histograms ) : output_filename = os . path . join ( model_dir , "text_metrics-{}-{}.txt" . format ( global_step , eval_tag ) ) with tf . gfile . Open ( output_filename , "w" ) as f : for k , v in sorted ( aggregates_dict [ _ROUGE_METRIC ] . items ( ) ) : f . write ( "%s-R,%f,%f,%f\n" % ( k , v . low . recall , v . mid . recall , v . high . recall ) ) f . write ( "%s-P,%f,%f,%f\n" % ( k , v . low . precision , v . mid . precision , v . high . precision ) ) f . write ( "%s-F,%f,%f,%f\n" % ( k , v . low . fmeasure , v . mid . fmeasure , v . high . fmeasure ) ) for k , v in sorted ( aggregates_dict [ _BLEU_METRIC ] . items ( ) ) : f . write ( "%s,%f,%f,%f\n" % ( k , v . low . bleu , v . mid . bleu , v . high . bleu ) ) for k , v in sorted ( aggregates_dict [ _REPETITION_METRIC ] . items ( ) ) : f . write ( "%s-T-token,%f,%f,%f\n" % ( k , v . low . target_ratio , v . mid . target_ratio , v . high . target_ratio ) ) f . write ( "%s-P-token,%f,%f,%f\n" % ( k , v . low . prediction_ratio , v . mid . prediction_ratio , v . high . prediction_ratio ) ) for k , v in sorted ( aggregates_dict [ _LENGTH_METRIC ] . items ( ) ) : f . write ( "%s-T,%f,%f,%f\n" % ( k , v . low . target_length , v . mid . target_length , v . high . target_length ) ) f . write ( "%s-P,%f,%f,%f\n" % ( k , v . low . prediction_length , v . mid . prediction_length , v . high . prediction_length ) ) f . write ( "%s-R,%f,%f,%f\n" % ( k , v . low . relative_length , v . mid . relative_length , v . high . relative_length ) ) for k , histogram in sorted ( length_histograms . items ( ) ) : f . write ( "%s-hist-T,%s\n" % ( k , str ( histogram . target ) ) ) f . write ( "%s-hist-P,%s\n" % ( k , str ( histogram . prediction ) ) ) f . write ( "%s-hist-R,%s\n" % ( k , str ( histogram . relative ) ) )