У меня есть следующий фрагмент кода python:
import numpy as np
# Some random array
x = np.random.rand(34, 176, 256)
# Get some indexes
pos_idx = np.argwhere(x > 0.5)
# Sample some values from these indexes
seeds = pos_idx[np.random.choice(pos_idx.shape[0], size=5, replace=False), :]
# Now create another array
y = np.zeros_like(x, np.uint8)
y[seeds] = 1
В последней строке дается ошибка, например:
index 77 is out of bounds for axis 0 with size 34
Но я не уверен, как это может произойти, поскольку все выбранные индексы должны быть действительными, поскольку они являются подмножеством.