如何确保我的图形元素之间的连接在 TensorBoard 中得到体现?

How do I ensure that connections among my graph elements are represented in TensorBoard?

在我的 TensorFlow 代码中,我将几个参数连接到图表中的某些逻辑,但是相应的 TensorBoard 可视化无法直接建立这些连接,而是仅指示包含范围之间的连接。

具体来说,我有

with tf.name_scope('params_structure'):
    is_train = tf.placeholder(tf.bool, [], name='is_train')
    keep_prob_later_param = tf.identity(FLAGS.keep_prob_later, name='keep_prob_later')
    keep_prob_early_param = tf.identity(FLAGS.keep_prob_early, name='keep_prob_early')
    keep_prob_input_param = tf.identity(FLAGS.keep_prob_input, name='keep_prob_input')

with tf.name_scope('structure_logic'):
    # Note that the summaries for these variables are the values used in training; not for computing stats
    with tf.name_scope('keep_prob_later_decay'):
        keep_prob_later_decay = tf.sub(1.0, tf.train.exponential_decay(1 - keep_prob_later_param, global_step,
                                                                       FLAGS.decay_steps,
                                                                       FLAGS.dropout_decay_rate, staircase=False))
    with tf.name_scope('keep_prob_early_decay'):
        keep_prob_early_decay = tf.sub(1.0, tf.train.exponential_decay(1 - keep_prob_early_param, global_step,
                                                                       FLAGS.decay_steps,
                                                                       FLAGS.dropout_decay_rate, staircase=False))
    with tf.name_scope('keep_prob_input_decay'):
        keep_prob_input_decay = tf.sub(1.0, tf.train.exponential_decay(1 - keep_prob_input_param, global_step,
                                                                       FLAGS.decay_steps,
                                                                       FLAGS.dropout_decay_rate, staircase=False))
    with tf.name_scope('keep_prob_all'):
        keep_prob_all = tf.identity(1.0)

    keep_prob_later = tf.cond(is_train, lambda: keep_prob_later_decay, lambda: keep_prob_all)
    keep_prob_early = tf.cond(is_train, lambda: keep_prob_early_decay, lambda: keep_prob_all)
    keep_prob_input = tf.cond(is_train, lambda: keep_prob_input_decay, lambda: keep_prob_all)

在我的 TensorBoard 可视化中,我按预期看到了所有这些元素,但未建立 keep_prob_..._param 和相应的 keep_prob_..._decay 操作之间的连接。相反,我只获得包含范围之间的连接作为一个组(例如,从下面突出显示的 params_structure 到所有 keep_prob_..._decay 操作):

is_train连接到条件操作中也是如此:仅连接整个包含范围(上面突出显示)。

如何确保我的图形元素之间的连接,而不仅仅是它们的封闭范围,在 TensorBoard 中表示?


请注意,这不仅仅是强制性完整性的问题:就目前而言,TensorBoard 表示完全无法确定 params_structure 元素中的哪些连接到 structure_logic 元素中的哪些:可以是任何一个,全部,甚至 none 个!

TensorBoard 必须选择表示形式,因为显示所有真实连接将是不可读的。这就是名称范围如此有用的原因:您可以查看整个图表,然后放大您感兴趣的元素。

但是,正如您所说,使用名称范围 TensorBoard 将显示两个框 param_structuresstructure_logic 之间的一个大连接(此连接中有 9 个张量)。

The TensorBoard representation completely fails to establish which of the params_structure elements connect to which of the structure_logic elements: it could be any, all, or even none of them!

这是错误的,Graph的所有信息都被代表了。
虽然没有以图形方式显示,但当您单击节点 params_structure/keep_prob_later 并看到右上角的框时,会写入 params_structure/keep_prob_laterstructure_logic/keep_prob_later_decay 之间的连接。
在类别 "Outputs" 中,您可以看到节点 structure_logic/keep_prob_later_decay.


如果你真的想看到连接,你应该把节点 keep_prob_later 放在名称范围 structure_logic/keep_prob_later_decay 中。


PS:

Note that this isn't just an issue of compulsive completeness.

那个让我笑了:)