Using numpy.argmax() on multidimensional arrays

前端 未结 2 1387
孤街浪徒
孤街浪徒 2020-12-31 08:37

I have a 4 dimensional array, i.e., data.shape = (20,30,33,288). I am finding the index of the closest array to n using

index = abs(data - n).a         


        
2条回答
  •  滥情空心
    2020-12-31 09:15

    You should be able to access the maximum values indexed by index using numpy.indices():

    x, z, t = numpy.indices(index.shape)
    data[x, index, z, t]
    

提交回复
热议问题