Is there a way to reshape an array into a certain shape padding missing dimensions?
Let's say, we have an array x
x = np.arange(10)
Now we want to reshape it to (1, 1, 1, 10, 1). We can do:
x = x.reshape((1, 1, 1, 10, 1))
or
x = x[None, None, None, x.shape[0], None]
But if the number and position of padding dimensions vary, this becomes quite inconvenient. Is there a better way?