结果的形状:np.random.randn(10,5) @ np.random.randn(5)

Shape of result: np.random.randn(10,5) @ np.random.randn(5)

这个 numpy 方程的结果等于 10 的形状是什么:np.random.randn(10,5) @ np.random.randn(5)。 谢谢大家。

根据 numpy.matmul 的文档页面:

If the second argument is 1-D, it is promoted to a matrix by appending a 1 to its dimensions. After matrix multiplication the appended 1 is removed.

这意味着在第二个操作数上附加一个额外的维度后,操作在两个二维数组(10, 5)(5, 1)之间执行。矩阵乘法遵循(i, j) @ (j, k) = (i, k)规则,所以输出的形状为(10, 1),然后移除额外附加的维度:(10,).