在Tensorflow中,如何解开tf.nn.max_pool_with_argmax获得的扁平化索引? [英] In Tensorflow, how to unravel the flattened indices obtained by tf.nn.max_pool_with_argmax?
问题描述
我遇到问题:使用 tf之后.nn.max_pool_with_argmax ,获得索引,即
argmax:Targmax类型的张量。 4维为每个输出选择的最大值的扁平化索引。
如何将扁平化索引解散回Tensorflow中的坐标列表? p>
非常感谢。
我今天遇到了同样的问题,我最终得到了这个解决方案:
def unravel_argmax(argmax,shape):
output_list = []
output_list.append(argmax //(shape [2] * shape [3]))
output_list.append(argmax%(shape [2] * shape [3])// shape [3])
返回tf.pack(output_list)
这是一个用法示例(我使用它将合并的argmax职位转发到我的分拆方法)
I meet a problem: After I use the tf.nn.max_pool_with_argmax, I obtain the indices i.e.
argmax: A Tensor of type Targmax. 4-D. The flattened indices of the max values chosen for each output.
How to unravel the flattened indices back to the coordinates list in Tensorflow?
Thank you very much.
I had the same problem today and I ended up with this solution:
def unravel_argmax(argmax, shape):
output_list = []
output_list.append(argmax // (shape[2] * shape[3]))
output_list.append(argmax % (shape[2] * shape[3]) // shape[3])
return tf.pack(output_list)
Here is an usage example in an ipython notebook (I use it to forward the pooling argmax positions to my unpooling method)
这篇关于在Tensorflow中,如何解开tf.nn.max_pool_with_argmax获得的扁平化索引?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!