【发布时间】:2021-07-18 05:56:33
【问题描述】:
我有这段代码可以帮助理解问题
hypotesisResult = (hypotesis(dataset, theta_init))
print(dataset.T.shape)
print(hypotesisResult.shape)
print(y.shape)
print((hypotesisResult - y).shape)
print(np.subtract(hypotesisResult, y).shape)
还有这个的输出:
(7, 1329)
(1329, 1)
(1329,1)
(1329, 1329)
(1329, 1329)
我的问题是,为什么如果 a 的矩阵 "hypotesisResult" 的大小为 (1329, 1),并且我从中减去 "y" (1329,1),它会得到 (1329,第1329章我做错了什么?我想要一个 (1329, 1) 的新矩阵,这就像一个标量减法
【问题讨论】:
-
结果形状表明其中一个数组是 (1329,) 或 (1,1329)
标签: python python-3.x numpy machine-learning