我正在基于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]
答案 0 :(得分:0)
我认为top_k运算符应该满足您的需求:
https://www.tensorflow.org/versions/r0.9/api_docs/python/nn.html#top_k