TensorBoard 中的 "reference edge" 是什么?

What is a "reference edge" in TensorBoard?

TensorBoard UI 显示了一种称为 "Reference edge" 的东西,与数据流 (Tensor) 边缘不同:

前者和后者有什么区别?

文档说 "the outgoing operation node can mutate the incoming tensor",但表示与 UI 不匹配的不同符号,因此很难说出 "incoming" 和 "outgoing" 的含义:

例如,这个定义如何适用于

cs = tf.constant([1,2,3], name='const_share')
vs = tf.Variable([1,2,3], name='var_share')
tf.add(cs, vs, name='opVS1')
tf.add(vs, cs, name='opVS2')

或到

tf.add([4],[3], name='opA')

在这两种情况下,参考边似乎表明它的尾部填充了边所代表的 Tensor 的值。

在您显示的图表中,看起来只有连接到 "read" 运算符的边是无向边 - dataflow edge,但是,您可以暂时断开 read 节点右键单击 "Remove from the main graph"。然后事实证明,边缘从数据流边缘(无向)变为参考边缘(有向),这没有多大意义。

我们可能需要指望真正理解 javascript 的人通过查看 tensorboard 的源代码来弄清楚它是如何工作的。

我在你的图表上没有看到任何参考边,但你可以通过以下方式轻松获得参考边:

import tensorflow as tf
a = tf.Variable(1, name="a")
b = a.assign_add(2)

with tf.Session() as sess:
    tf.summary.FileWriter('logs', sess.graph)
    sess.run(tf.global_variables_initializer())

当您单击 a 并将其从主图中删除时,您将看到一条参考边:

在 TF 中没有 bidirectional edges during the runtime. But there are some operations (like tf.assign_add) return 通过修改与输入之一相同的值:

ref: A mutable Tensor

所以 TF 添加了一个参考边,操作读取以前的值,做一些事情并用新值重写它。类比最有可能是 pointers/references。所以文档有点道理:

A reference edge showing that the outgoing operation node can mutate the incoming tensor.

这是混淆的根源,even to DeepMind developers and is being fixed in future releases因此:

  1. 所有参考边缘都将是不同的颜色(数据流边缘 和以前一样的灰色)。
  2. 指向所有数据流边缘的箭头,无论在哪里 他们指出(而不是只出现在数据流动的情况下 "downward").