import numpy as np
a=np.array([1,2,3,4,5,6,7,8,9,10,11,12])
b=np.reshape(a,(2,-1))
c=np.reshape(a,(2,2,-1))
d=np.reshape(a,(2,3,-1))
print 'b='
print b
print 'c='
print c
print 'd='
print d
result
b=
[[ 1 2 3 4 5 6]
[ 7 8 9 10 11 12]]
c=
[[[ 1 2 3]
[ 4 5 6]]
[[ 7 8 9]
[10 11 12]]]
d=
[[[ 1 2]
[ 3 4]
[ 5 6]]
[[ 7 8]
[ 9 10]
[11 12]]]
第一个数是矩阵数,第二个行数,第三个数是元素个数