Q:

How to get a 7x7 matrix numpy

I want to get a 7x7 matrix from my numpy array.
np.shape(y)

(1, 7, 7, 32)

np.shape(y[0][:][:][:])

(7, 7, 32)

np.shape(y[0][:][:][0])

(7, 32)

What I am doing wrong?

A:

You were probably thinking by analogy: "To get element i, j, k, l I can do
y[i][j][k][l]

if these indices are scalars, so why not for more general things like slices?"
The difference and reason why scalars work while slices don't is that scalar indexing removes dimensions, while slicing does not, so with y[i] having consumed the first dimension [j] targets the remaining first, i.e.the former second which is what you want. By contrast, y[:] leaves the first dimension in place, so the second and all following indexing operations mistarget.
This is only one of many reasons you should when dealing with multidimensional arrays virtually always prefer y[ind1, ind2, ind3, etc.] over y[ind1][ind2][ind3][etc.] be these indices scalars, slices or arrays.

