【发布时间】:2022-06-28 23:38:08
【问题描述】:
我正在尝试从一个 ndarray 获取 argmax 并使用它从另一个 ndarray 获取值,但我做错了。
ndvi_array = np.random.randint(0, 255, size=(4, 1, 100, 100))
image_array = np.random.randint(0, 255, size=(4, 12, 100, 100))
ndvi_argmax = ndvi_array.argmax(0)
print(f"NDVI argmax shape: {ndvi_argmax.shape}")
zipped = tuple(zip(range(len(ndvi_argmax)), ndvi_argmax))
result = image_array[zipped]
print(f"Result share: {result.shape}")
我收到以下错误:
only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices
如何获得具有最大值的形状数组 (1,12,100,100)?
【问题讨论】: