在Tensorboard中分组图

时间:2017-10-18 03:51:45

标签: python tensorflow tensorboard

我想将Tensorboard中的情节组织成小组。

例如,假设我在同一时间训练多个网络,他们每个人都有自己的准确性和损失步骤,并且通过网络分组准确性和丢失会很好。或者我想检查每层激活,平均重量,平均偏差,按层分组,以便更好地了解它们在训练过程中的变化。

我该怎么做?

1 个答案:

答案 0 :(得分:0)

尝试这样的事情:

import tensorflow as tf

# define first network
model_1 = tf.layers.dense(input1 , 100)
...
loss_1 = ...
summaries_1 = tf.summary.merge([tf.summary.scalar("loss_1", loss_1)])
train_op_1 = ...


# define second network
model_2 = tf.layers.dense(input2 , 100)
...
loss_2 = ...
summaries_2 = tf.summary.merge([tf.summary.scalar("loss_2", loss_2)])
train_op_2 = ...


#define file writer
fw = tf.summary.FileWriter(logdir='/tmp/my_logs')


sess = tf.Session()
# train your networks

for i in range(NUM_ITR):

    # train first net
    _, summary_str = sess.run([train_op_1, summaries_1])
    fw.add_summary(summary_str, global_step=i)

    # train second net
    _, summary_str = sess.run([train_op_2, summaries_2])
    fw.add_summary(summary_str, global_step=i)