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

30 lines
1.4 KiB
ReStructuredText
Raw Permalink 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(x1, x2, p=2.0)
计算两个Tensor每对行向量之间的p-norm距离。
.. note::
- Ascend上支持的输入数据类型为float16和float32。
- CPU上支持的输入数据类型为float16和float32。
- GPU上支持的输入数据类型为float32和float64。
参数:
- **x1** (Tensor) - 输入Tensorshape为 :math:`(B, P, M)` :math:`B` 表示0或者正整数。 :math:`B` 维度为0时该维度被忽略shape为 :math:`(P, M)`
- **x2** (Tensor) - 输入Tensorshape为 :math:`(B, R, M)` ,与 `x1` 的数据类型一致。
- **p** (float可选) - 计算向量对p-norm距离的P值P >= 0。默认 ``2.0``
返回:
Tensorp-范数距离,数据类型与 `x1` 一致shape为 :math:`(B, P, R)`
异常:
- **TypeError** - `x1``x2` 不是Tensor。
- **TypeError** - `x1``x2` 的数据类型不符合上述“说明”中的要求。
- **TypeError** - `p` 不是float32。
- **ValueError** - `p` 是负数。
- **ValueError** - `x1``x2` 维度不同。
- **ValueError** - `x1``x2` 的维度既不是2也不是3。
- **ValueError** - `x1``x2` 的批次维无法广播。
- **ValueError** - `x1``x2` 的列数不一样。