mindspore/docs/api/api_python/ops/mindspore.ops.func_cdist.rst

25 lines
1.2 KiB
ReStructuredText
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

mindspore.ops.cdist
===================
.. py:function:: mindspore.ops.cdist(x, y, p=2.0)
计算两个Tensor每对列向量之间的p-norm距离。
参数:
- **x** (Tensor) - 输入Tensorshape为 :math:`(B, P, M)` B维度为0时该维度被忽略shape为 :math:`(P, M)` 。在GPU上支持数据类型为[float32, float64]在CPU上支持[float32]。
- **y** (Tensor) - 输入Tensorshape为 :math:`(B, R, M)` ,与 `x` 的数据类型一致。
- **p** (float可选) - 计算向量对p-norm距离的P值P∈[0∞]。默认值:2.0。
返回:
Tensorp-范数距离,数据类型与 `x` 一致shape为(B, P, R)。
异常:
- **TypeError** - `x``y` 不是Tensor。
- **TypeError** - `x``y` 的数据类型在GPU环境不是float32或者float64在CPU环境不是float32。
- **TypeError** - `p` 不是float32。
- **ValueError** - `p` 是负数。
- **ValueError** - `x``y` 维度不同。
- **ValueError** - `x``y` 的维度既不是2也不是3。
- **ValueError** - 单批次训练下 `x``y` 的shape不一样。
- **ValueError** - `x``y` 的列数不一样。