How to reshape only last dimensions in numpy?

Viewed 3510

Suppose I have A of shape (...,96) and want to reshape it into (...,32,3) keeping both lengths and number of preceding dimensions, if ever, intact.

How to do this?

If I write

np.reshape(A, (-1, 32, 2))

it will flatten all preceding dimensions into one single, which I don't want.

1 Answers
Related