The argument indicates the shape of the array :
In [72]: import numpy as np In [73]: h = np.zeros((2,2,2)) In [74]: h.shape Out[74]: (2, 2, 2) In [75]: h = np.zeros((2,2,1)) In [76]: h.shape Out[76]: (2, 2, 1)
If the shape of the array is (a,b,c) , then it has an expression of 3 "axes" in NumPy (or in general English, 3 "dimensions"). Axis 0 has a length a , axis 1 has a length b , and axis 2 has a length c .
When you define h = np.zeros((2,2,1)) , note that the result has 3 levels of brackets:
In [77]: h Out[77]: array([[[ 0.], [ 0.]], [[ 0.], [ 0.]]])
The outermost bracket contains 2 elements, the middle brackets also contain 2 elements. The innermost bracket contains only one element. Thus, the form is (2, 2, 1).
source share