提取Tensorboard直方图数据

时间:2019-05-31 10:25:59

标签: tensorflow tensorflow-serving

the tutorial之后,我得到了Tensorflow的直方图,

import tensorflow as tf

k = tf.placeholder(tf.float32)

# Make a normal distribution, with a shifting mean
mean_moving_normal = tf.random_normal(shape=[1000], mean=(5*k), stddev=1)
# Record that distribution into a histogram summary
tf.summary.histogram("normal/moving_mean", mean_moving_normal)

# Setup a session and summary writer
sess = tf.Session()
writer = tf.summary.FileWriter("/tmp/histogram_example")

summaries = tf.summary.merge_all()

# Setup a loop and write the summaries to disk
N = 400
for step in range(N):
  k_val = step/float(N)
  summ = sess.run(summaries, feed_dict={k: k_val})
  writer.add_summary(summ, global_step=step)

下一步,我想使用Tensorboard API提取直方图数据,我的代码在这里

from tensorboard.backend.event_processing.event_accumulator import EventAccumulator
event_acc = EventAccumulator(summary_path)
event_acc.Reload()
# Show all tags in the log file
tags = event_acc.Tags()
hist_dict = {}
for hist_event in event_acc.Histograms('normal/moving_mean'):
    hist_dict.update({hist_event.step: (hist_event.histogram_value.bucket_limit,
                                        hist_event.histogram_value.bucket)})

但是,它仅返回最后的输出。如何获得所有数据?

1 个答案:

答案 0 :(得分:-1)

将“ size_guidance”传递给EventAccumulator构造函数时,您很高兴。像这样:

event_acc = EventAccumulator(path, size_guidance={
        'histograms': REAL_STEP_COUNT,
})