ValueError: operands could not be broadcast together with shapes (204,111104

报错

A=(D*W)

ValueError: operands could not be broadcast together with shapes (100,3) (3,100)

解决方法:

本人出现的问题是,D,W的大小分别为(100,3) (3,100), 是类型,而不是类型,直接进行乘积C = AB, 之后,提示上述错误,原因是数组大小“不一致”, 解决方案,不用 “ * ”符号,使用numpy中的dot()函数,可以实现两个二维数组的乘积,或者将数组类型转化为矩阵类型,使用""相乘,具体如下:
法一:

 A=dot(D,W)

法二:

D=mat(D)
W=mat(W)
A=D*W

你可能感兴趣的:(Python)