Извлечь данные гистограммы Tensorboard - PullRequest
0 голосов
/ 31 мая 2019

После урока я получил гистограмму от 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)

Следующий шаг, я хочу извлечь данные гистограммы, используя API Tensorboard, мой код здесь

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 голосов
/ 18 июня 2019

При передаче "size_guidance" в конструктор EventAccumulator, все готово. Что-то вроде:

event_acc = EventAccumulator(path, size_guidance={
        'histograms': REAL_STEP_COUNT,
})
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...