如何在张量流中通过其他索引张量选择张量元素

时间:2017-02-25 02:37:49

标签: python tensorflow

让我举一些我想要的例子。

print(num_tensor.get_shape())
>> [5, 6]

sess.run(num_tensor)
>> [[0, 1, 2, 3, 4, 5],
   [6, 7, 8, 9, 10, 11],
   [12, 13, 14, 15, 16, 17],
   [18, 19, 20, 21, 22, 23],
   [24, 25, 26, 27, 28, 29]]

print(index_tensor.get_shape()) # Same with num_tensor.get_shape[0]
>> [5]

sess.run(index_tensor)
>> [0, 2, 1, 3, 4]

我想让新张量通过index_tensor选择num_tensor的元素。

new_tensor = ... # Some operations
print(new_tensor.get_shape())
>> [5]
sess.run(new_tensor)
>> [0, 8, 13, 21, 28]

感谢您的帮助。

0 个答案:

没有答案