maxframe.learn.metrics.pairwise.manhattan_distances#
- maxframe.learn.metrics.pairwise.manhattan_distances(X, Y=None)[源代码]#
计算 X 和 Y 中向量之间的 L1 距离。
更多信息请参见 用户指南。
- 参数:
X (array_like) -- 形状为 (n_samples_X, n_features) 的张量。
Y (array_like, optional) -- 形状为 (n_samples_Y, n_features) 的张量。
- 返回:
D -- 形状为 (n_samples_X, n_samples_Y),D 包含成对的 L1 距离。
- 返回类型:
Tensor
示例
>>> from maxframe.learn.metrics.pairwise import manhattan_distances >>> manhattan_distances([[3]], [[3]]).execute() array([[0.]]) >>> manhattan_distances([[3]], [[2]]).execute() array([[1.]]) >>> manhattan_distances([[2]], [[3]]).execute() array([[1.]]) >>> manhattan_distances([[1, 2], [3, 4]], [[1, 2], [0, 3]]).execute() array([[0., 2.], [4., 4.]])