You can multiply the tuple (n,)by the number of sizes needed. eg:.
>>> import numpy as np
>>> N=2
>>> np.zeros((N,)*1)
array([ 0., 0.])
>>> np.zeros((N,)*2)
array([[ 0., 0.],
[ 0., 0.]])
>>> np.zeros((N,)*3)
array([[[ 0., 0.],
[ 0., 0.]],
[[ 0., 0.],
[ 0., 0.]]])
source
share