I would like to do a transformation like dimshuffle in theano using numpy.
Example input:
np.array([[1, 0, 0], [1, 0, 0]])
Example output:
np.array([
[[1, 0, 0], [1, 0, 0]],
[[1, 0, 0], [1, 0, 0]],
[[1, 0, 0], [1, 0, 0]]
])
I don't know what dimshuffle does, but the output can be produced with repeat
In [319]: np.repeat(np.array([[1, 0, 0], [1, 0, 0]])[None,:,:],3,axis=0)
Out[319]:
array([[[1, 0, 0],
[1, 0, 0]],
[[1, 0, 0],
[1, 0, 0]],
[[1, 0, 0],
[1, 0, 0]]])
The input is 2d (2,3), so I have to add an axis - output is (3,2,3). tile would work, so would indexing, or even:
A=np.array([[1, 0, 0], [1, 0, 0]])
np.array([A,A,A])