Lenar Hoyt Lenar Hoyt - 3 months ago 17
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?

Answer

You can use empty or zeros.

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

Comments