在numpy中,我有两个"数组",X是(m,n)和y是一个向量(n,1)
运用
X*y
Run Code Online (Sandbox Code Playgroud)
我收到了错误
ValueError: operands could not be broadcast together with shapes (97,2) (2,1)
Run Code Online (Sandbox Code Playgroud)
什么时候 (97,2)x(2,1)显然是一个法律矩阵操作,应该给我一个(97,1)向量
编辑:
我已经纠正了这一点,X.dot(y)但原始问题仍然存在.
我,我试图计算一组点和一个线段之间的最短距离.一切顺利,直到使用来自两组数组的值计算距离,一组用于x距离,一组用于y距离.
计算距离的线是:
d = np.sqrt( dx**2 + dy**2 ).
Run Code Online (Sandbox Code Playgroud)
它告诉我::
ValueError: operands could not be broadcast together with shapes (3312,) (0,)
Run Code Online (Sandbox Code Playgroud)
我之前使用过该脚本的另一组值,它完美无缺.但现在它已不复存在了.我试着找到错误信息的含义但到目前为止还没有成功.有人可以帮忙吗?