How to create 3 dimensions matrix in numpy , like matlab a(:,:,:) How to create 3 dimensions matrix in numpy , like matlab a(:,:,:) numpy numpy

How to create 3 dimensions matrix in numpy , like matlab a(:,:,:)


a=np.empty((2,3,5))

creates a 2x3x5 array. (There is also np.zeros if you want the values initialized.)

You can also reshape existing arrays:

a=np.arange(30).reshape(2,3,5)

np.arange(30) creates a 1-d array with values from 0..29. The reshape() method returns an array containing the same data with a new shape.