How can I initialize an empty Numpy array with a given number of dimensions?
<p>I basically want to initialize an empty 6-tensor, like this:</p>

<pre><code>a = np.array([[[[[[]]]]]])
</code></pre>

<p>Is there a better way than writing the brackets explicitly?</p>

<p>You could directly use the <a href="http://docs.scipy.org/doc/numpy/reference/generated/numpy.ndarray.html" rel="nofollow"><code>ndarray</code></a> constructor:</p>

<pre><code>numpy.ndarray(shape=(1,) * 6)
</code></pre>

<p>Or the <a href="http://docs.scipy.org/doc/numpy/reference/generated/numpy.empty.html" rel="nofollow"><code>empty</code></a> variant, since it seems to be more popular:</p>

<pre><code>numpy.empty(shape=(1,) * 6)
</code></pre>

python arrays numpy