If a is numpy array of shape (5,3) and b is of shape (2,4),what is the shape of a (b)?
Assuming the elements of b are valid indices into rows of a, then a[b] will be a 3D array with shape (2,4,3). In your example, that means b should be an integer array with values between -5 and 4 inclusive, else indexing a[b] will raise IndexError. The result a[b] will be made up of the corresponding rows from a, stacked in depth.
Comments
Leave a comment