I have a multidimensional numpy array X of shape: (B, dim, H, W) I would like to randomly sample k dim-dimensional vectors out of X.
I can get the sample indices from a msk of shape (B, 1, H, W):
sIdx = random.sample((msk.flat>=0).nonzero()[0], k)
But how can I efficiently slice X according to the "flat" sampled indices sIdx?
Aucun commentaire:
Enregistrer un commentaire