Numpy ndarray.shape() function can return the number of elements in each dimension of ndarray by tuple.

for example:

>>> x = np.array([1, 2, 3, 4]) >>> x.shape (4,)

We know x is 1 demension array, and the count of elements is 4

>>> y = np.zeros((2, 3, 4)) >>> y.shape (2, 3, 4)

Code above tell us that y is 3 demension array, and the count of elements is 2*3*4