Lenar Hoyt Lenar Hoyt - 7 months ago 45
Python Question

How can I initialize an empty Numpy array with a given number of dimensions?

I basically want to initialize an empty 6-tensor, like this:

a = np.array([[[[[[]]]]]])

Is there a better way than writing the brackets explicitly?


You can use empty or zeros.

For example, to create a new array of 2x3, filled with zeros, use: numpy.zeros(shape=(2,3))