Warm tip: This article is reproduced from serverfault.com, please click

Save histogram during evaluation with estimator api

发布于 2019-02-06 14:07:54

Is it possible to save a histogram during evaluation using the estimator API?

I couldn't find a solution since the estimator api does not write down any summaries during evaluation and I can only add scalars to the evaluates metrics.

Questioner
Natjo
Viewed
0
yonatansc97 2020-11-28 16:58:01

For the sake of those who came here and haven't found a solution, I will update that I used the above approach, with a slight modification:

    summary_writer = tf.compat.v1.summary.FileWriter(
        logdir=self.model_dir + '/eval_histograms/',
        filename_suffix='.host_call')
    summary_ops = [tf.compat.v1.summary.histogram(name=k, values=v)
                   for k, v in
                   prepare_endpoints_for_summary(endpoints).items()]
    eval_hooks = [
        tf.estimator.SummarySaverHook(save_steps=1,
                                      summary_writer=summary_writer,
                                      summary_op=summary_op)
        for summary_op in summary_ops]

And it worked fine! enter image description here