expose Primitve APIs part1
This commit is contained in:
parent
c03a1aeeff
commit
480b88de4e
|
@ -213,6 +213,7 @@ mindspore.ops.function
|
|||
mindspore.ops.matrix_determinant
|
||||
mindspore.ops.mul
|
||||
mindspore.ops.multiply
|
||||
mindspore.ops.mvlgamma
|
||||
mindspore.ops.neg
|
||||
mindspore.ops.negative
|
||||
mindspore.ops.positive
|
||||
|
@ -387,6 +388,7 @@ Array操作
|
|||
mindspore.ops.normal
|
||||
mindspore.ops.nonzero
|
||||
mindspore.ops.numel
|
||||
mindspore.ops.orgqr
|
||||
mindspore.ops.permute
|
||||
mindspore.ops.population_count
|
||||
mindspore.ops.range
|
||||
|
|
|
@ -69,6 +69,8 @@ MindSpore中 `mindspore.ops` 接口与上一版本相比,新增、删除和支
|
|||
mindspore.ops.MaxPoolWithArgmax
|
||||
mindspore.ops.MaxUnpool2D
|
||||
mindspore.ops.MirrorPad
|
||||
mindspore.ops.NthElement
|
||||
mindspore.ops.NuclearNorm
|
||||
mindspore.ops.Pad
|
||||
mindspore.ops.EmbeddingLookup
|
||||
mindspore.ops.Padding
|
||||
|
@ -91,6 +93,8 @@ MindSpore中 `mindspore.ops` 接口与上一版本相比,新增、删除和支
|
|||
mindspore.ops.CTCLossV2
|
||||
mindspore.ops.KLDivLoss
|
||||
mindspore.ops.L2Loss
|
||||
mindspore.ops.MultilabelMarginLoss
|
||||
mindspore.ops.MultiMarginLoss
|
||||
mindspore.ops.NLLLoss
|
||||
mindspore.ops.RNNTLoss
|
||||
mindspore.ops.SigmoidCrossEntropyWithLogits
|
||||
|
@ -207,6 +211,7 @@ MindSpore中 `mindspore.ops` 接口与上一版本相比,新增、删除和支
|
|||
mindspore.ops.IOU
|
||||
mindspore.ops.L2Normalize
|
||||
mindspore.ops.NMSWithMask
|
||||
mindspore.ops.NonMaxSuppressionWithOverlaps
|
||||
mindspore.ops.RGBToHSV
|
||||
mindspore.ops.ROIAlign
|
||||
mindspore.ops.SampleDistortedBoundingBoxV2
|
||||
|
@ -304,6 +309,7 @@ MindSpore中 `mindspore.ops` 接口与上一版本相比,新增、删除和支
|
|||
mindspore.ops.Mul
|
||||
mindspore.ops.MulNoNan
|
||||
mindspore.ops.Neg
|
||||
mindspore.ops.NextAfter
|
||||
mindspore.ops.Pow
|
||||
mindspore.ops.Real
|
||||
mindspore.ops.RealDiv
|
||||
|
@ -385,6 +391,7 @@ Reduction算子
|
|||
mindspore.ops.Ger
|
||||
mindspore.ops.MatMul
|
||||
mindspore.ops.MatrixInverse
|
||||
mindspore.ops.Orgqr
|
||||
mindspore.ops.Svd
|
||||
mindspore.ops.TridiagonalMatMul
|
||||
|
||||
|
@ -419,6 +426,7 @@ Tensor创建
|
|||
|
||||
mindspore.ops.Gamma
|
||||
mindspore.ops.Multinomial
|
||||
mindspore.ops.NonDeterministicInts
|
||||
mindspore.ops.RandomCategorical
|
||||
mindspore.ops.RandomChoiceWithMask
|
||||
mindspore.ops.Randperm
|
||||
|
@ -481,6 +489,8 @@ Array操作
|
|||
mindspore.ops.MatrixSolve
|
||||
mindspore.ops.MatrixTriangularSolve
|
||||
mindspore.ops.Meshgrid
|
||||
mindspore.ops.Mvlgamma
|
||||
mindspore.ops.Nonzero
|
||||
mindspore.ops.ParallelConcat
|
||||
mindspore.ops.PopulationCount
|
||||
mindspore.ops.Range
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
mindspore.ops.NthElement
|
||||
========================
|
||||
|
||||
.. py:class:: mindspore.ops.NthElement(reverse=False)
|
||||
|
||||
寻找并返回输入Tensor最后一维第 :math:`n` 小的值。
|
||||
如果输入是Vector(rank为1),寻找第n小的值并以Scalar Tensor类型输出结果。
|
||||
对于Matrix(rank大于1),计算最后一维每一行(各自可以看作一个Vector)第n小的值。因此,返回值 `values` 的shape满足 `values`.shape = `input`.shape[:-1]。
|
||||
|
||||
参数:
|
||||
- **reverse** (bool,可选) - 可选参数,如果设为True,则寻找第 :math:`n` 大的值,如果设为False,则寻找第n小的值。默认值:False。
|
||||
|
||||
输入:
|
||||
- **input** (Tensor) - 一维或者更高维度的Tensor,最后一维的大小必须大于等于 :math:`n+1` 。
|
||||
- **n** (Union[int, Tensor]) - 如果 :math:`n` 为Tensor,则必须是0维的,数据类型是int32。 :math:`n` 的有效范围是::math:`[0, input.shape[-1])` 。
|
||||
|
||||
输出:
|
||||
- **values** (Tensor) - 其shape满足: `values`.shape = `input`.shape[:-1],数据类型与 `input` 一致。
|
||||
|
||||
异常:
|
||||
- **TypeError** - `input` 的数据类型不在有效类型列表内。
|
||||
- **TypeError** - `n` 不是int32或者Tensor。
|
||||
- **ValueError** - `n` 不在 :math:`[0, input.shape[-1])` 范围内。
|
|
@ -0,0 +1,8 @@
|
|||
mindspore.ops.MultiMarginLoss
|
||||
==================================
|
||||
|
||||
.. py:class:: mindspore.ops.MultiMarginLoss(reduction='mean')
|
||||
|
||||
创建一个标准,用于优化输入和输出之间的多类分类铰链损失(基于边距的损失)。
|
||||
|
||||
更多细节请参考 :func:`mindspore.ops.multi_margin_loss` 。
|
|
@ -0,0 +1,11 @@
|
|||
mindspore.ops.MultilabelMarginLoss
|
||||
==================================
|
||||
|
||||
.. py:class:: mindspore.ops.MultilabelMarginLoss(reduction='none')
|
||||
|
||||
二维卷积层。
|
||||
|
||||
创建一个标准,用于优化输入 :math:`x` (一个2D小批量Tensor)
|
||||
和输出 :math:`y` (一个目标类别索引的2DTensor)之间的多类分类铰链损失(基于边距的损失)。
|
||||
|
||||
更多细节请参考 :func:`mindspore.ops.multi_label_margin_loss` 。
|
|
@ -0,0 +1,8 @@
|
|||
mindspore.ops.Mvlgamma
|
||||
==================================
|
||||
|
||||
.. py:class:: mindspore.ops.Mvlgamma
|
||||
|
||||
逐元素计算 `p` 维多元对数伽马函数值。
|
||||
|
||||
更多细节请参考 :func:`mindspore.ops.mvlgamma` 。
|
|
@ -0,0 +1,24 @@
|
|||
mindspore.ops.NextAfter
|
||||
=======================
|
||||
|
||||
.. py:class:: mindspore.ops.NextAfter
|
||||
|
||||
返回 `x2` 方向上查找的 `x1` 的下一个可表示值的数字。
|
||||
|
||||
.. math::
|
||||
out_{i} = nextafter{x1_{i}, x2_{i}}
|
||||
|
||||
更多详细信息请参见 `A Self Regularized Non-Monotonic Neural Activation Function <https://arxiv.org/abs/1908.08681>`_ 。
|
||||
|
||||
输入:
|
||||
- **x1** (Tensor) - 支持数据类型为float32和float64。其shape为 :math:`(N,*)` ,其中 :math:`*` 为任意数量的额外维度。
|
||||
- **x2** (Tensor) - 支持数据类型为float32和float64。其shape为 :math:`(N,*)` ,其中 :math:`*` 为任意数量的额外维度。
|
||||
|
||||
输出:
|
||||
Tensor,shape和数据类型与 `x1` 相同。
|
||||
|
||||
异常:
|
||||
- **TypeError** - `x1` 和 `x2` 都不是Tensor。
|
||||
- **TypeError** - `x1` 和 `x2` 的数据类型非float16或float32。
|
||||
- **TypeError** - `x1` 和 `x2` 数据类型不一致。
|
||||
- **ValueError** - `x1` 和 `x2` 的shape不一致。
|
|
@ -0,0 +1,28 @@
|
|||
mindspore.ops.NonDeterministicInts
|
||||
===================================
|
||||
|
||||
.. py:class:: mindspore.ops.NonDeterministicInts(dtype=mindspore.int64)
|
||||
|
||||
生成指定数据类型范围内的随机整数。
|
||||
|
||||
返回Tensor的shape由输入 `shape` 指定,其中的随机数从指定数据类型的可表示范围内抽取。
|
||||
|
||||
.. warning::
|
||||
`shape` 中的值必须大于零,输出元素总数不可超过1000000。
|
||||
|
||||
参数:
|
||||
- **dtype** (mindspore.dtype,可选) - 输出数据类型。支持的数据类型为:mindspore.int32和mindspore.int64。默认值:mindspore.int64。
|
||||
|
||||
输入:
|
||||
- **shape** (Tensor) - 输出Tensor的shape。支持的数据类型为:int32和int64。
|
||||
|
||||
输出:
|
||||
Tensor,其shape由输入 `shape` 指定,数据类型由参数 `dtype` 指定。
|
||||
|
||||
异常:
|
||||
- **TypeError** - `shape` 不是Tensor。
|
||||
- **ValueError** - `dtype` 不是mindspore.int32或mindspore.int64。
|
||||
- **ValueError** - `shape` 中含有负数。
|
||||
- **ValueError** - `shape` 元素个数少于2。
|
||||
- **ValueError** - `shape` 不是一维Tensor。
|
||||
- **ValueError** - 输出元素总个数大于1000000。
|
|
@ -0,0 +1,32 @@
|
|||
mindspore.ops.NonMaxSuppressionWithOverlaps
|
||||
============================================
|
||||
|
||||
.. py:class:: mindspore.ops.NonMaxSuppressionWithOverlaps
|
||||
|
||||
贪婪选取一组按score降序排列后的边界框。
|
||||
|
||||
.. note::
|
||||
- 此算法与原点在坐标系中的位置无关。
|
||||
- 对于坐标系的正交变换和平移,该算法不受影响;因此坐标系的平移变换后算法会选择相同的框。
|
||||
|
||||
输入:
|
||||
- **overlaps** (Tensor) - 二维Tensor,其shape为 :math:`(num_boxes, num_boxes)` ,表示n乘n的边框重叠值。支持的数据类型为float32。
|
||||
- **scores** (Tensor) - 一维Tensor,其shape为 :math:`(num_boxes)` 。表示对应每一行每个方框的score值, `scores` 和 `overlaps` 的num_boxes必须相等。支持的数据类型为float32。
|
||||
- **max_output_size** (Union[Tensor, Number.Int]) - 选取最大的边框数,必须大于等于0,数据类型为int32。
|
||||
- **overlap_threshold** (Union[Tensor, Number.Float]) - 边框重叠值阈值,重叠值大于此值说明重叠过大。支持的数据类型为float32。
|
||||
- **score_threshold** (Union[Tensor, Number.Float]) - 移除边框阈值,边框score值大于此值则移除相应边框。支持的数据类型为float32。
|
||||
|
||||
输出:
|
||||
一维Tensor,表示被选中边框的index,其shape为 :math:`(M)` ,其中M <= `max_output_size`。数据类型为int32。
|
||||
|
||||
异常:
|
||||
- **TypeError** - `overlaps` 、 `scores` 、 `overlap_threshold` 和 `score_threshold` 的数据类型不是float32。
|
||||
- **TypeError** - `overlaps` 或者 `scores` 不是Tesnor。
|
||||
- **TypeError** - `max_output_size` 不是Tesnor或者Scalar,或者其数据类型不是int32。
|
||||
- **TypeError** - `overlap_threshold` 不是Tesnor或者Scalar,或者其数据类型不是float32。
|
||||
- **TypeError** - `score_threshold` 不是Tesnor或者Scalar,或者其数据类型不是float32。
|
||||
- **ValueError** - `overlaps` 长度不等于2或者其shape的两个值不相等。
|
||||
- **ValueError** - `scores` 的shape长度不是1。
|
||||
- **ValueError** - `max_output_size` 、 `overlap_threshold` 或者 `score_threshold` 的shape长度不是1。
|
||||
- **ValueError** - `max_output_size` 小于零。
|
||||
- **ValueError** - `scores` shape的大小与 `overlaps` 的第0或第1维不相等。
|
|
@ -0,0 +1,8 @@
|
|||
mindspore.nn.Nonzero
|
||||
====================
|
||||
|
||||
.. py:class:: mindspore.nn.Nonzero()
|
||||
|
||||
计算输入Tensor中所有非零元素的下标。
|
||||
|
||||
更多细节请参考 :func:`mindspore.ops.nonzero` 。
|
|
@ -0,0 +1,36 @@
|
|||
mindspore.ops.NuclearNorm
|
||||
==========================
|
||||
|
||||
.. py:class:: mindspore.ops.NuclearNorm(dim=None, keepdim=False)
|
||||
|
||||
返回给定Tensor的矩阵核范数。
|
||||
|
||||
属性 `dim` 指定输入 `x` 的哪两个维度计算核范数。如果 `dim` 为None,则核规范将在输入所有维度上计算。
|
||||
因为核范数是矩阵的奇异值之和,此时的输入应该是二维的。也就是说,如果输入是二维,我们计算输入矩阵的核范数。此时, `dim` 应设为None。
|
||||
如果你设置了 `dim` ,它也需要在适当的范围内,否则将不生效。如果输入为三维及以上,属性 `dim` 是必需的。它指定了在哪两个输入维度计算核范数。
|
||||
|
||||
根据 `dim` 列表,输入Tensor根据 `dim` 重新排列。 `dim` 指定的两个维度将被放在末尾,其他维度的顺序相对不变。对每个调整后的Tensor的切片执行SVD以获得奇异值,将所有奇异值求和即为获得核规范。
|
||||
|
||||
参数:
|
||||
- **dim** (Union[list(int), tuple(int)],可选) - 指定计算 `x` 矩阵核范数的哪两个维度,如果 `dim` 为None,则核规范将在输入所有维度上计算。 `dim` 的长度应该是2,其值应在此范围内::math:`[-x_rank,x_rank)` 。x_rank是 `x` 的维度。dim[0]和dim[1]的值不能指向相同的维度。默认值:None。
|
||||
- **keep_dim** (bool,可选) - 输出Tensor是否保留维度。默认值:False。
|
||||
|
||||
输入:
|
||||
- **x** (Tensor) - 计算矩阵核范数的Tensor。 `x` 的维度应该大于等于2,数据类型为float32或者float64。
|
||||
|
||||
输出:
|
||||
Tensor,如果 `keepdim` 为True,将输入中 `dim` 指定的维度变为1后即为输出shape,否则 `dim` 中指定维度被移除。数据类型与 `x` 一致。
|
||||
|
||||
|
||||
异常:
|
||||
- **TypeError** - `x` 不是Tensor。
|
||||
- **TypeError** - `x` 的数据类型float32 或 float64。
|
||||
- **TypeError** - `dim` 的数据类型不是list(int) 或者 tuple(int)。
|
||||
- **TypeError** - `keepdim` 的数据类型不是bool。
|
||||
- **ValueError** - `x` 的维度小于2。
|
||||
- **ValueError** - 指定的 `dim` 的长度不等于2。
|
||||
- **ValueError** - 没有指定 `dim` 的时候, `x` 的维度不等于2。
|
||||
- **ValueError** - `dim[0]` 和 `dim[1]` 指向相同的维度。
|
||||
- **ValueError** - `dim[0]` 或者 `dim[1]` 超出范围::math:`[-x_rank, x_rank)` ,其中x_rank 为 `x` 的维度。
|
||||
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
mindspore.ops.Orgqr
|
||||
====================
|
||||
|
||||
.. py:class:: mindspore.ops.Orgqr
|
||||
|
||||
计算 `Householder <https://en.wikipedia.org/wiki/Householder_transformation#Householder_matrix>`_ 矩阵乘积的前 :math:`N` 列。
|
||||
|
||||
更多细节请参考 :func:`mindspore.ops.orgqr` 。
|
|
@ -0,0 +1,27 @@
|
|||
mindspore.ops.mvlgamma
|
||||
=======================
|
||||
|
||||
.. py:function:: mindspore.ops.mvlgamma(input, p)
|
||||
|
||||
逐元素计算 `p` 维多元对数伽马函数值。
|
||||
|
||||
Mvlgamma计算公式如下:
|
||||
|
||||
.. math::
|
||||
|
||||
\log (\Gamma_{p}(a))=C+\sum_{i=1}^{p} \log (\Gamma(a-\frac{i-1}{2}))
|
||||
|
||||
其中 :math:`C = \log(\pi) \times \frac{p(p-1)}{4}` ,:math:`\Gamma(\cdot)` 为Gamma函数。
|
||||
|
||||
参数:
|
||||
- **input** (Tensor) - 多元对数伽马函数的输入Tensor,支持数据类型为float32和float64。其shape为 :math:`(N,*)` ,其中 :math:`*` 为任意数量的额外维度。 `input` 中每个元素的值必须大于 :math:`(p - 1) / 2` 。
|
||||
- **p** (int) - 进行计算的维度,必须大于等于1。
|
||||
|
||||
返回:
|
||||
Tensor。shape和类型与 `input` 一致。
|
||||
|
||||
异常:
|
||||
- **TypeError** - `input` 的数据类型不是float32或者float64。
|
||||
- **TypeError** - `p` 不是int类型。
|
||||
- **TypeError** - `p` 小于1。
|
||||
- **TypeError** - `input` 中不是所有元素的值都大于 :math:`(p - 1) / 2` 。
|
|
@ -0,0 +1,28 @@
|
|||
mindspore.ops.orgqr
|
||||
====================
|
||||
.. py:function:: mindspore.ops.orgqr(x, tau)
|
||||
|
||||
计算 `Householder <https://en.wikipedia.org/wiki/Householder_transformation#Householder_matrix>`_ 矩阵乘积的前 :math:`N` 列。
|
||||
以输入无批次的情况为例, 假设输入x的shape经过 `Householder转换 <https://en.wikipedia.org/wiki/Householder_transformation#Householder_matrix>`_ 之后为::math:`(M, N)` 。
|
||||
当 `x` 的对角线被置为1, `x` 中下三角形的每一列都表示为: :math:`w_j` ,其中 :math:`j` 在 :math:`j=1, \ldots, M` 范围内,此函数返回Householder矩阵乘积的前 :math:`N` 列:
|
||||
|
||||
.. math::
|
||||
H_{1} H_{2} \ldots H_{k} \quad \text { with } \quad H_{j}=\mathrm{I}_{M}-\tau_{j} w_{j} w_{j}^{\mathrm{H}}
|
||||
|
||||
其中::math:`\mathrm{I}_{M}`是 :math:`M` 维单位矩阵。当 :math:`w` 是复数的时候,:math:`w^{\mathrm{H}}` 是共轭转置,否则是一般转置。输出矩阵的shape与输入矩阵 `x` 相同。
|
||||
|
||||
参数:
|
||||
- **x** (Tensor) - shape :math:`(*, M, N)` 的Tensor,表示2维或者3维矩阵。数据类型为float32、float64、complex64或者complex128。
|
||||
- **tau** (Tensor) - Householder转换的反射系数,其shape为 :math:`(*, K)` ,其中 `K` 小于等于 `N` 。数据类型与 `x` 一致。
|
||||
|
||||
返回:
|
||||
Tensor,数据类型与shape与 `x` 一致。
|
||||
|
||||
异常:
|
||||
- **TypeError** - `x` 或者 `tau` 不是Tensor。
|
||||
- **TypeError** - `x` 和 `tau` 的数据类型不是float64、float32、complex64或者complex128。
|
||||
- **ValueError** - `x` 和 `tau` 的batch维度不同。
|
||||
- **ValueError** - `x`.shape[-2] < `x`.shape[-1]。
|
||||
- **ValueError** - `x`.shape[-1] < `tau`.shape[-1]。
|
||||
- **ValueError** - rank(`x`) - rank(`tau`) != 1。
|
||||
- **ValueError** - rank(`x`) != 2 or 3。
|
|
@ -214,6 +214,7 @@ Element-by-Element Operations
|
|||
mindspore.ops.matrix_determinant
|
||||
mindspore.ops.mul
|
||||
mindspore.ops.multiply
|
||||
mindspore.ops.mvlgamma
|
||||
mindspore.ops.neg
|
||||
mindspore.ops.negative
|
||||
mindspore.ops.positive
|
||||
|
@ -387,6 +388,7 @@ Array Operation
|
|||
mindspore.ops.normal
|
||||
mindspore.ops.nonzero
|
||||
mindspore.ops.numel
|
||||
mindspore.ops.orgqr
|
||||
mindspore.ops.permute
|
||||
mindspore.ops.population_count
|
||||
mindspore.ops.range
|
||||
|
|
|
@ -69,6 +69,8 @@ Neural Network
|
|||
mindspore.ops.MaxPoolWithArgmax
|
||||
mindspore.ops.MaxUnpool2D
|
||||
mindspore.ops.MirrorPad
|
||||
mindspore.ops.NthElement
|
||||
mindspore.ops.NuclearNorm
|
||||
mindspore.ops.Pad
|
||||
mindspore.ops.EmbeddingLookup
|
||||
mindspore.ops.Padding
|
||||
|
@ -91,6 +93,8 @@ Loss Function
|
|||
mindspore.ops.CTCLossV2
|
||||
mindspore.ops.KLDivLoss
|
||||
mindspore.ops.L2Loss
|
||||
mindspore.ops.MultilabelMarginLoss
|
||||
mindspore.ops.MultiMarginLoss
|
||||
mindspore.ops.NLLLoss
|
||||
mindspore.ops.RNNTLoss
|
||||
mindspore.ops.SigmoidCrossEntropyWithLogits
|
||||
|
@ -206,6 +210,7 @@ Image Processing
|
|||
mindspore.ops.IOU
|
||||
mindspore.ops.L2Normalize
|
||||
mindspore.ops.NMSWithMask
|
||||
mindspore.ops.NonMaxSuppressionWithOverlaps
|
||||
mindspore.ops.RGBToHSV
|
||||
mindspore.ops.ROIAlign
|
||||
mindspore.ops.SampleDistortedBoundingBoxV2
|
||||
|
@ -303,6 +308,7 @@ Element-wise Operator
|
|||
mindspore.ops.Mul
|
||||
mindspore.ops.MulNoNan
|
||||
mindspore.ops.Neg
|
||||
mindspore.ops.NextAfter
|
||||
mindspore.ops.Pow
|
||||
mindspore.ops.Real
|
||||
mindspore.ops.RealDiv
|
||||
|
@ -384,6 +390,7 @@ Linear Algebraic Operator
|
|||
mindspore.ops.Ger
|
||||
mindspore.ops.MatMul
|
||||
mindspore.ops.MatrixInverse
|
||||
mindspore.ops.Orgqr
|
||||
mindspore.ops.Svd
|
||||
mindspore.ops.TridiagonalMatMul
|
||||
|
||||
|
@ -418,6 +425,7 @@ Random Generation Operator
|
|||
|
||||
mindspore.ops.Gamma
|
||||
mindspore.ops.Multinomial
|
||||
mindspore.ops.NonDeterministicInts
|
||||
mindspore.ops.RandomCategorical
|
||||
mindspore.ops.RandomChoiceWithMask
|
||||
mindspore.ops.Randperm
|
||||
|
@ -480,6 +488,8 @@ Array Operation
|
|||
mindspore.ops.MatrixSolve
|
||||
mindspore.ops.MatrixTriangularSolve
|
||||
mindspore.ops.Meshgrid
|
||||
mindspore.ops.Mvlgamma
|
||||
mindspore.ops.Nonzero
|
||||
mindspore.ops.ParallelConcat
|
||||
mindspore.ops.PopulationCount
|
||||
mindspore.ops.Range
|
||||
|
|
|
@ -5001,9 +5001,9 @@ def lstsq(input, A):
|
|||
|
||||
def mvlgamma(input, p):
|
||||
r"""
|
||||
Computes the multivariate log-gamma function with dimension p element-wise.
|
||||
Computes the multivariate log-gamma function with dimension `p` element-wise.
|
||||
|
||||
The following tex shows the mathematical calculation process of Mvlgamma:
|
||||
The mathematical calculation process of Mvlgamma is shown as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
|
@ -5015,7 +5015,7 @@ def mvlgamma(input, p):
|
|||
input (Tensor): The tensor to compute the multivariate log-gamma function,
|
||||
which must be one of the following types: float32, float64.
|
||||
The shape is :math:`(N,*)`, where :math:`*` means any number of additional dimensions.
|
||||
And the value of any element in `input` must be greater than (p - 1) / 2.
|
||||
And the value of any element in `input` must be greater than :math:`(p - 1) / 2`.
|
||||
p (int): The number of dimensions. And the value of `p` must be greater than or equal to 1.
|
||||
|
||||
Returns:
|
||||
|
@ -5024,8 +5024,8 @@ def mvlgamma(input, p):
|
|||
Raises:
|
||||
TypeError: If dtype of `input` is neither float32 nor float64.
|
||||
TypeError: If `p` is not an int.
|
||||
ValueError: If `p` is not greater than or equal to 1.
|
||||
ValueError: If all elements of `input` are not greater than (p-1)/2.
|
||||
ValueError: If `p` is less than 1.
|
||||
ValueError: If not all elements of `input` are greater than :math:`(p - 1) / 2`.
|
||||
|
||||
Supported Platforms:
|
||||
``CPU`` ``GPU``
|
||||
|
|
|
@ -3460,9 +3460,12 @@ def median(x, axis=-1, keepdims=False):
|
|||
|
||||
def orgqr(x, tau):
|
||||
r"""
|
||||
Computes the first :math:`N` columns of a product of Householder matrices. Take the case of input without batch
|
||||
as an example. The input x is a matrix of size :math:`(M, N)` after householder transformation. When the diagonal
|
||||
of x is set to 1, every colunm of lower triangular in x is denoted as :math:`w_j` for :math:`j` for
|
||||
Computes the first :math:`N` columns of a product of
|
||||
`Householder <https://en.wikipedia.org/wiki/Householder_transformation#Householder_matrix>`_
|
||||
matrices. Take the case of input without batch
|
||||
as an example. Suppose input `x` is a matrix of size :math:`(M, N)` after householder transformation.
|
||||
When the diagonal of `x` is set to 1, every colunm of lower triangular in `x` is
|
||||
denoted as :math:`w_j` for :math:`j` for
|
||||
:math:`j=1, \ldots, M`, this function returns the first :math:`N` columns of the matrix
|
||||
|
||||
.. math::
|
||||
|
@ -3470,13 +3473,13 @@ def orgqr(x, tau):
|
|||
|
||||
where :math:`\mathrm{I}_{M}` is the :math:`M`-dimensional identity matrix. And when :math:`w` is complex,
|
||||
:math:`w^{\mathrm{H}}` is the conjugate transpose, otherwise the transpose.
|
||||
The output matrix is the same size as the input matrix :math:`x`.
|
||||
The output matrix is the same size as the input matrix `x`.
|
||||
|
||||
Args:
|
||||
x (Tensor): Tensor of shape :math:`(*, M, N)`, indicating 2D or 3D matrices,
|
||||
with float32, float64, complex64 and complex128 data type.
|
||||
tau (Tensor) : Tensor of shape :math:`(*, K)`, where `K` is less than or equal to `N` indicating the
|
||||
reflecting coefficient in Householder transformation, which have the same type as x.
|
||||
with float32, float64, complex64 and complex128 data type.
|
||||
tau (Tensor): Tensor of shape :math:`(*, K)`, where `K` is less than or equal to `N`, indicating the
|
||||
reflecting coefficient in Householder transformation, which have the same type as `x`.
|
||||
|
||||
Returns:
|
||||
Tensor, has the same shape and data type as `x`.
|
||||
|
|
|
@ -3581,33 +3581,9 @@ class DiagPart(PrimitiveWithCheck):
|
|||
|
||||
class Mvlgamma(Primitive):
|
||||
r"""
|
||||
Computes the multivariate log-gamma function with dimension p element-wise.
|
||||
Computes the multivariate log-gamma function with dimension `p` element-wise.
|
||||
|
||||
The following tex shows the mathematical calculation process of Mvlgamma:
|
||||
|
||||
.. math::
|
||||
|
||||
\log (\Gamma_{p}(a))=C+\sum_{i=1}^{p} \log (\Gamma(a-\frac{i-1}{2}))
|
||||
|
||||
where :math:`C = \log(\pi) \times \frac{p(p-1)}{4}` and :math:`\Gamma(\cdot)` is the Gamma function.
|
||||
|
||||
Args:
|
||||
p(int): The number of dimensions. And the value of `p` must be greater than or equal to 1.
|
||||
|
||||
Inputs:
|
||||
- **x** (Tensor) - The tensor to compute the multivariate log-gamma function,
|
||||
which must be one of the following types: float32, float64.
|
||||
The shape is :math:`(N,*)`, where :math:`*` means any number of additional dimensions.
|
||||
And the value of any element in `x` must be greater than (p - 1) / 2.
|
||||
|
||||
Outputs:
|
||||
Tensor, has the same shape and type as `x`.
|
||||
|
||||
Raises:
|
||||
TypeError: If dtype of `x` is neither float32 nor float64.
|
||||
TypeError: If `p` is not an int.
|
||||
ValueError: If `p` is not greater than or equal to 1.
|
||||
ValueError: If all elements of `x` are not greater than (p-1)/2.
|
||||
Refer to :func:`mindspore.ops.mvlgamma` for more details.
|
||||
|
||||
Supported Platforms:
|
||||
``Ascend`` ``CPU`` ``GPU``
|
||||
|
|
|
@ -417,45 +417,43 @@ class NonMaxSuppressionWithOverlaps(Primitive):
|
|||
Greedily selects a subset of bounding boxes in descending order of score.
|
||||
|
||||
Note:
|
||||
This algorithm is agnostic to where the origin is in the coordinate system.
|
||||
This algorithm is invariant to orthogonal transformations and translations of the coordinate system;
|
||||
thus translating or reflections of the coordinate system result in the same boxes being
|
||||
selected by the algorithm.
|
||||
- This algorithm is agnostic to where the origin is in the coordinate system.
|
||||
- This algorithm is invariant to orthogonal transformations and translations of the coordinate system;
|
||||
thus translating or reflections of the coordinate system result in the same boxes being
|
||||
selected by the algorithm.
|
||||
|
||||
Inputs:
|
||||
- **overlaps** (Tensor) - A 2-D Tensor of shape [num_boxes, num_boxes].
|
||||
Types allowed:float32.
|
||||
- **scores** (Tensor) - A 1-D Tensor of shape [num_boxes] representing a single score
|
||||
corresponding to each box (each row of boxes),the num_boxes of "scores" must be equal to
|
||||
the num_boxes of "overlaps".
|
||||
- **overlaps** (Tensor) - A 2-D Tensor of shape :math:`(num_boxes, num_boxes)`,
|
||||
representing the n-by-n box overlap values. Types allowed:float32.
|
||||
- **scores** (Tensor) - A 1-D Tensor of shape :math:`(num_boxes)` representing a single score
|
||||
corresponding to each box (each row of boxes), the num_boxes of `scores` must be equal to
|
||||
the num_boxes of `overlaps`.
|
||||
Types allowed:float32.
|
||||
- **max_output_size** (Union[Tensor, Number.Int]) - A scalar integer Tensor representing the maximum
|
||||
number of boxes to be selected by non max suppression, and max_output_size must be equal to or greater
|
||||
than 0.
|
||||
Types allowed:int32.
|
||||
- **overlap_threshold** (Union[Tensor, Number.Float]) - A 0-D float tensor representing the threshold for
|
||||
- **overlap_threshold** (Union[Tensor, Number.Float]) - A 0-D float Tensor representing the threshold for
|
||||
deciding whether boxes overlap too much.
|
||||
Types allowed:float32.
|
||||
- **score_threshold** (Union[Tensor, Number.Float]) - A 0-D float tensor representing the threshold for
|
||||
- **score_threshold** (Union[Tensor, Number.Float]) - A 0-D float Tensor representing the threshold for
|
||||
deciding when to remove boxes based on score.
|
||||
Types allowed:float32.
|
||||
|
||||
Outputs:
|
||||
An int32 tensor. A 1-D integer Tensor of shape [M] representing the selected indices from the boxes tensor,
|
||||
where M <= max_output_size.
|
||||
A 1-D integer Tensor of shape :math:`(M)` representing the selected indices from the boxes Tensor,
|
||||
where M <= max_output_size. Its data type is int32.
|
||||
|
||||
Raises:
|
||||
TypeError: If the dtype of `overlaps` and `scores` is not float32.
|
||||
TypeError: If the dtype of `overlap_threshold` and `score_threshold` is not float32.
|
||||
TypeError: If `overlaps` is not tensor or its dtype is not float32.
|
||||
TypeError: If `scores` is not tensor or its dtype is not float32.
|
||||
TypeError: If `max_output_size` is not tensor or scalar.If `max_output_size` is not int32.
|
||||
TypeError: If `overlap_threshold` is not tensor or scalar. If its type is not float32.
|
||||
TypeError: If `score_threshold` is not tensor or scalar. If its type is not float32.
|
||||
TypeError: If the dtype of `overlaps` , `scores` `overlap_threshold` and `score_threshold` is not float32.
|
||||
TypeError: If `overlaps` or `scores` is not Tensor。
|
||||
TypeError: If `max_output_size` is not Tensor or Scalar.If `max_output_size` is not int32.
|
||||
TypeError: If `overlap_threshold` is not Tensor or scalar. If its type is not float32.
|
||||
TypeError: If `score_threshold` is not Tensor or scalar. If its type is not float32.
|
||||
ValueError: If the size of shape of `overlaps` is not 2 or the second value of its shape
|
||||
is not equal to the first value of its shape.
|
||||
ValueError: If the size of shape of `scores` is not 1.
|
||||
ValueError: If each of the size of shape of `max_output_size`, `overlap_threshold`, `score_threshold` is not 0.
|
||||
ValueError: If any of the size of shape of `max_output_size`, `overlap_threshold`, `score_threshold` is not 0.
|
||||
ValueError: If `max_output_size` is negative.
|
||||
ValueError: If the shape of `scores` is not equal to the shape of the dim0 or dim1 of `overlaps`.
|
||||
|
||||
|
|
|
@ -7233,7 +7233,7 @@ class Polar(Primitive):
|
|||
|
||||
class NextAfter(Primitive):
|
||||
"""
|
||||
Returns the next representable value after the given first number in the direction of given second number.
|
||||
Returns the next representable value after `x1` in the direction of `x2`.
|
||||
|
||||
.. math::
|
||||
|
||||
|
@ -7249,12 +7249,12 @@ class NextAfter(Primitive):
|
|||
Must be one of the following types: float32, float64.
|
||||
|
||||
Outputs:
|
||||
Tensor, has the same shape and data type as `x`.
|
||||
Tensor, has the same shape and data type as `x1`.
|
||||
|
||||
Raises:
|
||||
TypeError: If neither `x1` nor `x2` is a Tensor.
|
||||
TypeError: If the dtype of input is not one of: float32, float64.
|
||||
TypeError: If the dtypes of two inputs are not same.
|
||||
TypeError: If the dtype of `x1` and `x2` is not one of: float32, float64.
|
||||
TypeError: If the dtypes of `x1` and `x2` are not same.
|
||||
ValueError: If `x1`'s shape is not the same as `x2`.
|
||||
|
||||
Supported Platforms:
|
||||
|
@ -7473,35 +7473,9 @@ class NanToNum(Primitive):
|
|||
|
||||
class Orgqr(Primitive):
|
||||
r"""
|
||||
Computes the first :math:`N` columns of a product of Householder matrices. Take the case of input without batch
|
||||
as an example. The input x is a matrix of size :math:`(M, N)` after householder transformation. When the diagonal
|
||||
of x is set to 1, every colunm of lower triangular in x is denoted as :math:`w_j` for :math:`j` for
|
||||
:math:`j=1, \ldots, M`, this function returns the first :math:`N` columns of the matrix
|
||||
Computes the first :math:`N` columns of a product of Householder matrices.
|
||||
|
||||
.. math::
|
||||
H_{1} H_{2} \ldots H_{k} \quad \text { with } \quad H_{j}=\mathrm{I}_{M}-\tau_{j} w_{j} w_{j}^{\mathrm{H}}
|
||||
|
||||
where :math:`\mathrm{I}_{M}` is the :math:`M`-dimensional identity matrix. And when :math:`w` is complex,
|
||||
:math:`w^{\mathrm{H}}` is the conjugate transpose, otherwise the transpose.
|
||||
The output matrix is the same size as the input matrix :math:`x`.
|
||||
|
||||
Inputs:
|
||||
- **x** (Tensor) - Tensor of shape :math:`(*, M, N)`, indicating matrices greater than or equal to 2D,
|
||||
with float32, float64, complex64 and complex128 data type.
|
||||
- **tau** (Tensor) - Tensor of shape :math:`(*, K)`, where `K` is less than or equal to `N`, indicating the
|
||||
reflecting coefficient in Householder transformation, which have the same type as x.
|
||||
|
||||
Outputs:
|
||||
Tensor, has the same shape and data type as `x`.
|
||||
|
||||
Raises:
|
||||
TypeError: If `x` or `tau` are not Tensors.
|
||||
TypeError: If dtype of `x` and `tau` is not one of: float64, float32, complex64, complex128.
|
||||
ValueError: If `x` and `tau` have different batch size.
|
||||
ValueError: If x.shape[-2] < x.shape[-1].
|
||||
ValueError: If x.shape[-1] < tau.shape[-1].
|
||||
ValueError: If rank(x) - rank(tau) != 1.
|
||||
ValueError: If rank(x) < 2.
|
||||
Refer to :func:`mindspore.ops.orgqr` for more details.
|
||||
|
||||
Supported Platforms:
|
||||
``Ascend`` ``GPU`` ``CPU``
|
||||
|
|
|
@ -2999,10 +2999,9 @@ class SmoothL1Loss(Primitive):
|
|||
class MultiMarginLoss(Primitive):
|
||||
r"""
|
||||
Creates a criterion that optimizes a multi-class classification hinge loss (margin-based loss)
|
||||
between input xx (a 2D mini-batch Tensor) and output yy (which is a 1D tensor of target class
|
||||
indices, 0 \leq y \leq \text{x.size}(1)-10≤y≤x.size(1)−1):
|
||||
between input and output.
|
||||
|
||||
Refer to :func:`mindspore.ops.multi_margin_loss` for more detail.
|
||||
Refer to :func:`mindspore.ops.multi_margin_loss` for more details.
|
||||
|
||||
Supported Platforms:
|
||||
``Ascend`` ``CPU``
|
||||
|
@ -8871,7 +8870,7 @@ class MultilabelMarginLoss(Primitive):
|
|||
hinge loss (margin-based loss) between input :math:`x` (a 2D mini-batch `Tensor`)
|
||||
and output :math:`y` (which is a 2D `Tensor` of target class indices).
|
||||
|
||||
Refer to :func:`mindspore.ops.multi_label_margin_loss` for more detail.
|
||||
Refer to :func:`mindspore.ops.multi_label_margin_loss` for more details.
|
||||
|
||||
Supported Platforms:
|
||||
``Ascend`` ``GPU``
|
||||
|
@ -9340,22 +9339,22 @@ class NthElement(Primitive):
|
|||
each row (resp. vector along the last dimension). Thus, values.shape = input.shape[:-1].
|
||||
|
||||
Args:
|
||||
reverse (bool): An optional bool. Defaults to False. When set to True, find the nth-largest value
|
||||
in the vector and vice versa.
|
||||
reverse (bool, optional): An optional bool. When set to True, find the nth-largest value
|
||||
in the vector and vice versa. Default: False.
|
||||
|
||||
Inputs:
|
||||
- **input** (Tensor) - A Tensor. 1-D or higher with last dimension at least n+1.
|
||||
- **n** (int or Tensor) - If the n is a tensor, it should be a 0-D tensor, dtype is int32.
|
||||
Valid range of n is [0, input.shape[-1]).
|
||||
- **input** (Tensor) - A Tensor. 1-D or higher with last dimension at least :math:`n+1`.
|
||||
- **n** (Union[int, Tensor]) - If the n is a tensor, it should be a 0-D tensor, dtype is int32.
|
||||
Valid range of n is :math:`[0, input.shape[-1])`.
|
||||
|
||||
Outputs:
|
||||
Tensor, values.shape = input.shape[:-1]. The dtype is same to the input.
|
||||
- **values** (Tensor) - Its shape satisfies: `values`.shape = `input`.shape[:-1].
|
||||
The dtype is the same as `input`.
|
||||
|
||||
Raises:
|
||||
TypeError: If the type of input is out of the valid list.
|
||||
TypeError: If the n is not int32 or not a Tensor.
|
||||
ValueError: If n is out of [0, input.shape[-1]).
|
||||
|
||||
TypeError**: If the type of `input` is out of the valid list.
|
||||
TypeError**: If `n` is not int32 or not a Tensor.
|
||||
ValueError**: If n is out of :math:`[0, input.shape[-1])`.
|
||||
|
||||
Supported Platforms:
|
||||
``Ascend`` ``GPU`` ``CPU``
|
||||
|
@ -10064,50 +10063,51 @@ class SparseApplyProximalGradientDescent(Primitive):
|
|||
|
||||
class NuclearNorm(Primitive):
|
||||
r"""
|
||||
Returns the matrix nuclear norm of a given tensor.
|
||||
Returns the matrix nuclear norm of a given Tensor.
|
||||
|
||||
Attr `dim` specifies which two dimensions of the input `x` to calculate the nuclear norm across. If `dim` is None,
|
||||
the nuclear norm will be calculated across all dimensions of input. Because the nuclear norm is the sum of the
|
||||
singular values of the matrix, the input at this time should be 2-dimensional. That is, if the input is
|
||||
2-dimensional, we compute the nuclear norm of the input matrix. At this point, `dim` should be None. If you set
|
||||
`dim`, it also needs to be in the proper range, although it doesn't work. If the input is 3-dimensional and above,
|
||||
`dim`, it also needs to be in the proper range, otherwise it wonn't work. If the input is 3-dimensional and above,
|
||||
the attribute `dim` is required. It specifies which two dimensions of input to calculate the nuclear norm across.
|
||||
|
||||
According to the `dim` list, the input tensor is reordered by `dim`. The two dimensions pointed to by the attribute
|
||||
According to the `dim` list, the input Tensor is reordered by `dim`. The two dimensions pointed to by the attribute
|
||||
`dim` are placed at the end, and the order of the other dimensions is relatively unchanged. Perform the SVD of each
|
||||
slice of the adjusted tensor to obtain the singular value. Sum all of the singular value of each slice/matrix to
|
||||
slice of the adjusted Tensor to obtain the singular value. Sum all of the singular value of each slice/matrix to
|
||||
obtain the nuclear norm.
|
||||
|
||||
Args:
|
||||
dim (Union[list(int), tuple(int)]): Specifies which two dimensions of `x` to calculate the matrix nuclear norm
|
||||
dim (Union[list(int), tuple(int)], optional): Specifies which two
|
||||
dimensions of `x` to calculate the matrix nuclear norm
|
||||
across. If `dim` is None, the nuclear norm will be calculated across all dimensions of `x`. The length of
|
||||
`dim` should be 2. The value in `dim` should be in this range:[-x_rank, x_rank). x_rank is the dimension of
|
||||
Tensor `x`. The value of `dim[0]` or `dim[1]` can not point to the same dimension. Default: None.
|
||||
keepdim (bool): whether the output tensor have `dim` retained or not. Default: False.
|
||||
keepdim (bool, optional): Whether the output Tensor have `dim` retained or not. Default: False.
|
||||
|
||||
Inputs:
|
||||
- **x** (Tensor) - Input to compute the matrix nuclear norm. The dimension of `x` should be greater than or
|
||||
equal to 2. Data type must be float32 or float64.
|
||||
|
||||
Outputs:
|
||||
Tensor, output tensor with dimensions in `dim` reduced to 1 will be returned if `keepdim` is `True`;
|
||||
otherwise a tensor with dimensions in `dim` removed is returned. The data type is same as `x`.
|
||||
|
||||
Supported Platforms:
|
||||
``Ascend`` ``CPU``
|
||||
Tensor, output Tensor with dimensions in `dim` reduced to 1 will be returned if `keepdim` is `True`;
|
||||
otherwise a Tensor with dimensions in `dim` removed is returned. The data type is same as `x`.
|
||||
|
||||
Raises:
|
||||
TypeError: If `x` is not a tensor.
|
||||
TypeError: If `x` is not a Tensor.
|
||||
TypeError: If dtype of `x` is neither float32 nor float64.
|
||||
TypeError: If dtype of `dim` is neither list(int) nor tuple(int).
|
||||
TypeError: If dtype of `keepdim` is not bool.
|
||||
ValueError: If dimension of Tensor `x` is less than 2.
|
||||
ValueError: If the length of `dim` is not 2 when `dim` is set.
|
||||
ValueError: If the dimension of tensor `x` is not 2 when `dim` is not set.
|
||||
ValueError: If the dimension of Tensor `x` is not 2 when `dim` is not set.
|
||||
ValueError: If `dim[0]` or `dim[1]` point to the same dimension.
|
||||
ValueError: If `dim[0]` or `dim[1]` is not in this range:[-x_rank, x_rank).
|
||||
x_rank is the dimension of Tensor `x`.
|
||||
|
||||
Supported Platforms:
|
||||
``Ascend`` ``CPU``
|
||||
|
||||
Examples:
|
||||
>>> input_x = Tensor(np.array([[[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]],
|
||||
... [[7.0, 8.0, 9.0], [10.0, 11.0, 12.0]]]), ms.float32)
|
||||
|
|
|
@ -30,22 +30,23 @@ class NonDeterministicInts(Primitive):
|
|||
that a given type can represent.
|
||||
|
||||
.. warning::
|
||||
The value of "shape" must be greater than zero. The output length must be less than 1000000.
|
||||
The value of `shape` must be greater than zero.
|
||||
The number of elements of output can not exceed 1000000.
|
||||
|
||||
Args:
|
||||
dtype (mindspore.dtype): The type of output. Its value must be one of the following types: mindspore.int32
|
||||
and mindspore.int64. Default: mindspore.int64.
|
||||
- **dtype** (mindspore.dtype, optional) - The date type of output. The supported values are: mindspore.int32
|
||||
and mindspore.int64. Default: mindspore.int64.
|
||||
|
||||
Inputs:
|
||||
- **shape** (Tensor) - The shape of random tensor to be generated. Its type must be one of the following types:
|
||||
mindspore.int32 and mindspore.int64.
|
||||
- **shape** (Tensor) - The shape of random tensor to be generated. The supported values are:
|
||||
int32 and int64.
|
||||
|
||||
Outputs:
|
||||
Tensor. Its shape is specified by the input `shape`. Its type is specified by `dtype`.
|
||||
|
||||
Raises:
|
||||
TypeError: If `shape` is not a Tensor.
|
||||
TypeError: If `dtype` and input tensor type are not allowed.
|
||||
TypeError: If `dtype` is not mindspore.int32 or mindspore.int64.
|
||||
ValueError: If `shape` has negative elements.
|
||||
ValueError: If `shape` has less than 2 elements.
|
||||
ValueError: If `shape` is not a 1-D tensor.
|
||||
|
|
Loading…
Reference in New Issue