【发布时间】:2018-03-02 08:44:33
【问题描述】:
在某些情况下,张量流似乎能够在图创建时检查张量的值,而在其他情况下则失败。
>>> shape = [constant([2])[0], 3]
>>> reshape([1,2,3,4,5,6], shape)
<tf.Tensor 'Reshape_13:0' shape=(2, 3) dtype=int32>
>>> zeros(shape)
<tf.Tensor 'zeros_2:0' shape=(?, 3) dtype=float32>
在上面的例子中,reshape() 可以看到作为 shape 传入的张量的值为 2,结果输出的 shape 为 (2,3) 但 zeros() 不能,静态 shape 为 ( ?,3)。造成差异的原因是什么?
我的同事发布了Determining tensor shapes at time of graph creation in TensorFlow,它基于相同的潜在问题,但他提出了一个稍微不同的问题,即如何最好地使用 tensorflow 来解决这类问题,而我的问题是关于为什么 tensorflow 会这样方法。是bug吗?
【问题讨论】:
标签: python tensorflow