Python中报错提示ValueError: setting an array element with a sequence.

Python中报错提示ValueError: setting an array element with a sequence.

出错位置:

x[k] = xj @ bj
# 其中xj是一个 n*2 的矩阵,bj:2*1

显然出现在了矩阵的维数,这也不是我想要的结果。

于是按照正确的模型算法将代码写为如下,并运行成功:

x[k] = xj[k,:] @ bj

ValueError: matmul: Input operand 1 has a mismatch in its core dimension 0, with gufunc signature (n?,k),(k,m?)->(n?,m?) (size 2 is different from 1)

矩阵做乘法时维数出现问题

方法: 更改矩阵维数

猜你喜欢

转载自blog.csdn.net/GODSuner/article/details/113706602