Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/310.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 另一张量的大小范围';s维_Python_Tensorflow - Fatal编程技术网

Python 另一张量的大小范围';s维

Python 另一张量的大小范围';s维,python,tensorflow,Python,Tensorflow,我想在下面的问题中计算张量的子集: 我有一个张量T和一个索引张量I。我想得到一个张量C,这样: C[i] = T[i, I[i]] 要做到这一点,我想我会: first_dim = I.get_shape()[0] R = tf.range(first_dim) S = tf.stack([R, I], 1) tf.gather(T, S) 但我在第二行有个问题: ValueError: Cannot convert an unknown Dimension to a Tensor: ?

我想在下面的问题中计算张量的子集: 我有一个张量
T
和一个索引张量
I
。我想得到一个张量
C
,这样:

C[i] = T[i, I[i]]
要做到这一点,我想我会:

first_dim = I.get_shape()[0]
R = tf.range(first_dim)
S = tf.stack([R, I], 1)
tf.gather(T, S)
但我在第二行有个问题:

ValueError: Cannot convert an unknown Dimension to a Tensor: ?

I
的形状取决于某个占位符的大小。有没有其他方法来解决我的问题或获得另一个张量维度的大小范围,这在TF图编译时是未知的?

使用
TF.shape
而不是
get\u shape

尝试过了,它仍然说第一个维度是未定义的。