如果我在Python重塑我用这个:重塑在朱莉娅
import numpy as np
y= np.asarray([1,2,3,4,5,6,7,8])
x=2
z=y.reshape(-1, x)
print(z)
,并得到这个
>>>
[[1 2]
[3 4]
[5 6]
[7 8]]
我将如何获得朱莉娅是一回事吗?我想:
z = [1,2,3,4,5,6,7,8]
x= 2
a=reshape(z,x,4)
println(a)
,它给了我:
[1 3 5 7
2 4 6 8]
如果我使用reshape(z,4,x)
它会给
[1 5
2 6
3 7
4 8]
而且是有办法做到重塑没有指定如第二维reshape(z,x)
或次要维度更模糊?
'reshape(z,4,x)'看起来像你想要的,不是? – StefanKarpinski 2014-11-04 11:46:25
@StefanKarpinski没有那会给[1,5]作为前两个数字没有[1,2] – ccsv 2014-11-04 11:52:19