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

tensorflow-使用Estimator API在评估过程中保存直方图

(tensorflow - Save histogram during evaluation with estimator api)

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

是否可以在使用估算器API的评估过程中保存直方图?

我找不到解决方案,因为estimator api在评估过程中不会写下任何摘要,而且我只能将标量添加到评估指标中。

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

为了那些来到这里但还没有找到解决方案的人,我将更新为我使用了上面的方法,并做了一些修改:

    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]

而且效果很好! 在此处输入图片说明