无法在张量流变量中制作动态维度



我有以下代码:

a = tf.placeholder(dtype = tf.float64, shape = (10, None))
b = tf.Variable(tf.random_normal((20, 10), dtype = tf.float64), dtype = tf.float64)
c = tf.matmul(b, a)
d = tf.shape(a)[1]
e = tf.Variable(tf.random_normal((d, d), dtype = tf.float64), dtype = tf.float64)

我想在执行期间设置e的维度。但是我得到一个错误。不可能吗?

不,这是不可能的。Tensorflow 不允许在变量定义中使用动态形状,因为它无法在图定义期间分配任意大小的内存。因此,e的维度必须静态地知道。

最新更新