Lenar Hoyt Lenar Hoyt - 1 year ago 123
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 Source

You can use empty or zeros.

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download