如何在TensorFlow中获得最大3张量?

时间:2016-06-14 19:17:40

标签: python tensorflow

我正在基于TensorFlow在seq2seq中构建自己的注意力模型。我想知道如何在TensorFlow中执行以下伪代码:

att = [0.2,0.3,0.5,0.1,0.9,0.2]# This is a tensor or a list of tensors
result = maximum3numbers(att)

可接受的结果可能是:

result = [0.9,0.5,0.3]

result = [4,2,1]

1 个答案:

答案 0 :(得分:0)

我认为top_k运算符应该满足您的需求:

https://www.tensorflow.org/versions/r0.9/api_docs/python/nn.html#top_k