ValueError: operands could not be broadcast together with shapes解决

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

import numpy as np
a=np.array([[1,2]])
b=np.array([[1,5,3]])
print(a+b)

原因:a与b的shape不同,所以报错,解决方法。维度调成相同即可

猜你喜欢

转载自blog.csdn.net/jacke121/article/details/81535135