Python 计算Numpy向量之间的欧氏距离

vector1 = np.array([1,2,3])  
vector2 = np.array([4,5,6])
dist = numpy.sqrt(numpy.sum(numpy.square(vector1 - vector2 )))

dist = numpy.linalg.norm(vector1 - vector2 )

猜你喜欢

转载自blog.csdn.net/ctwy291314/article/details/88403070