mindspore.ops.cond

查看源文件
mindspore.ops.cond(A, p=None)[源代码]

返回给定Tensor的矩阵范数或向量范数。

p 为norm的计算模式。支持下列norm模式。

说明

当前暂不支持复数。

参数:
  • A (Tensor) - 输入Tensor,包含零个或多个batch维度。

  • p (Union[int, float, inf, -inf, 'fro', 'nuc'], 可选) - norm的模式,参考上表,默认 None

返回:

Tensor

支持平台:

GPU CPU

样例:

>>> import mindspore
>>> x = mindspore.tensor([[1.0, 0.0, -1.0], [0.0, 1.0, 0.0], [1.0, 0.0, 1.0]])
>>> print(mindspore.ops.cond(x))
1.4142
>>> print(mindspore.ops.cond(x, 'fro'))
3.1622777