I'm trying to take certain data out of a tensor, but I get weird error. Here, I will try to generate the error:
a=np.random.randn(5, 10, 5, 5)
a[:, [1, 6], np.triu_indices(5, 0)[0], np.triu_indices(5, 0)[1]].shape
I get this error
shape mismatch: indexing arrays could not be broadcast together with shapes
I'm not even doing any broadcasting! it is all slicing stuff.
What do I want? leave zeroth axis as is (get everything), get [1] and [6] from first axis, reshape the last two axes from [5, 5] to [15] by taking upper triangle elements only.