Search code examples
tensorflowhistogramtensorboard

Save histogram during evaluation with estimator api


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.


Solution

  • 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