【发布时间】:2018-07-12 04:13:08
【问题描述】:
我有一个张量“idx”,它作为下面代码的结果返回。该代码使用了另外三个名为“result”、“theta”和“user”的张量,它们都在下面的输出中进行了描述。我对 tensorflow 很陌生,我试图了解 idx 是什么,文档对 shape=(1,) 是什么有点不清楚。是向量还是矩阵?有没有办法访问 idx 的元素?我尝试了 idx[1] 或 idx[1,],但出现了超出范围的错误。
非常感谢任何提示。
Code:
result
Output:
<tf.Tensor 'DVBPR_1/Add_2:0' shape=(1, 100) dtype=float32>
Code:
thetau
Output:
<tf.Variable 'DVBPR/Variable:0' shape=(20, 100) dtype=float32_ref>
Code:
user
Output:
<tf.Tensor 'Placeholder_3:0' shape=(1,) dtype=int32>
Code:
idx = tf.reduce_sum(tf.matmul(result,tf.transpose(tf.gather(thetau,user))),1)
idx
Output:
<tf.Tensor 'Sum_1:0' shape=(1,) dtype=float32>
【问题讨论】:
-
已经有很好的讨论here
标签: python-2.7 tensorflow