import numpy as np
x = np.array([[1,2,3],[4,5,6]])
输出x
[[1 2 3]
[4 5 6]]
转为行向量
x=x.reshape(-1)
输出行向量
[1 2 3 4 5 6]
转为列向量
x=x.reshape((-1,1))
输出列向量
[[1]
[2]
[3]
[4]
[5]
[6]]
import numpy as np
x = np.array([[1,2,3],[4,5,6]])
输出x
[[1 2 3]
[4 5 6]]
转为行向量
x=x.reshape(-1)
输出行向量
[1 2 3 4 5 6]
转为列向量
x=x.reshape((-1,1))
输出列向量
[[1]
[2]
[3]
[4]
[5]
[6]]