ValueError: operands could not be broadcast together with shapes (3000,20) (20,20)
来源:互联网 发布:vb中len函数的使用方法 编辑:程序博客网 时间:2024/06/06 15:43
本人出现的问题是,两个数组A,B的大小分别为(3000,20) (20,20), 是<numpy.ndarray>类型,而不是<matrix>类型,直接进行乘积C = A*B, 之后,提示上述错误,原因是数组大小“不一致”, 解决方案,不用"*"符号,使用numpy中的dot()函数,可以实现两个二维数组的乘积,或者将数组类型转化为矩阵类型,使用"*"相乘,具体如下:
- A = numpy.array([1,2], [3,4], [5,6]) # 3*2 numpy.ndarray
- B = numpy.array([1,2,3], [4,5,6]) # 2*3 numpy.ndarray
- C = A * B # raise error: ValueError: operands could not be broadcast together with shapes (3,2) (2,2)
- # solution method 1
- C = numpy.dot(A, B) # C: 3*3 numpy.ndarray
- # solution method 2
- A_mat = numpy.matrix(A)
- B_mat = numpy.matrix(B)
- C = A_mat * B_mat # C: 3*3 numpy.matrixlib.defmatrix.matrix
0 0
- ValueError: operands could not be broadcast together with shapes (3000,20) (20,20)
- python问题:ValueError: operands could not be broadcast together with shapes (100,3) (3,1)
- Faster RCNN训练出现问题:ValueError: operands could not be broadcast together with shapes
- operands could not be broadcast together with shapes
- ValueError: could not broadcast input array from shape (300,2,300,1) into shape (300,2,1,1)
- MBean with the same name could not be unregisted
- String could not be serialized with encoding: 4
- A server with the specified hostname could not be found.
- ValueError: "concat" mode can only merge layers with matching output shapes except for the concat
- ValueError: Shapes (40, 4, 4, 1) and (?, 8, 8, 1) are not compatible
- ValueError: could not convert string to float的处理方式
- builtins.ValueError: could not convert string to float:的问题
- ValueError: A 0.7-series setuptools cannot be installed with distribute.
- hdu2270 How Many Friends Will Be Together With You
- XXX could not be redeployed because it could not be...
- Mutex could not be created
- Mutex could not be created
- save could not be completed
- [LeetCode] Find Minimum in Rotated Sorted Array
- android面试の通过Intent传递一些二进制数据的方法有哪些
- Vendor推薦可逆的加密方式
- Step into MongoDB - 15 - GridFS
- Android的Log输出新包装
- ValueError: operands could not be broadcast together with shapes (3000,20) (20,20)
- android启动过程
- 如何给标签增加圆形边缘
- CKeditor 配置使用
- ceph 随笔1
- 通过IL分析C#中的委托、事件、Func、Action、Predicate之间的区别与联系
- 设计模式基础
- leetcode 日经贴,Cpp code -Reverse Nodes in k-Group
- 流动的网页背景代码,是不是很漂亮