设x是形为(10,)的矩阵。
我试过了
x=np.reshape(x, [1,10])发生错误
错误:无法将大小为(10,)的x调整为1,10
如何应对?
发布于 2020-05-12 09:26:08
如果x的形状为(10,),则np.array([x])的形状为(1,10)。
这将创建数组的副本,因此它可能不是最有效的解决方案,但很简单。
发布于 2020-05-12 09:30:45
reshape函数中的-1表示第一个形状:
a = np.array([1,2,3,4,5,6,7,8,9,10])
print(a.shape) # (10,)
a = a.reshape(1, -1)
print(a.shape) # (1, 10)https://stackoverflow.com/questions/61742181
复制相似问题