forked from mindspore-Ecosystem/mindspore
add api doc
This commit is contained in:
parent
9839e1ba11
commit
2c46f3301b
|
@ -251,6 +251,7 @@ Dropout层
|
|||
mindspore.nn.MultiClassDiceLoss
|
||||
mindspore.nn.MultiLabelSoftMarginLoss
|
||||
mindspore.nn.NLLLoss
|
||||
mindspore.nn.PoissonNLLLoss
|
||||
mindspore.nn.RMSELoss
|
||||
mindspore.nn.SampledSoftmaxLoss
|
||||
mindspore.nn.SmoothL1Loss
|
||||
|
@ -373,6 +374,8 @@ Dynamic LR函数
|
|||
|
||||
mindspore.nn.ChannelShuffle
|
||||
mindspore.nn.Flatten
|
||||
mindspore.nn.Identity
|
||||
mindspore.nn.Unflatten
|
||||
|
||||
数学运算
|
||||
----------
|
||||
|
|
|
@ -115,6 +115,7 @@ mindspore.ops
|
|||
:template: classtemplate.rst
|
||||
|
||||
mindspore.ops.cdist
|
||||
mindspore.ops.dist
|
||||
mindspore.ops.pdist
|
||||
|
||||
采样函数
|
||||
|
@ -219,6 +220,7 @@ mindspore.ops
|
|||
mindspore.ops.erfc
|
||||
mindspore.ops.erfinv
|
||||
mindspore.ops.exp
|
||||
mindspore.ops.exp2
|
||||
mindspore.ops.expm1
|
||||
mindspore.ops.floor
|
||||
mindspore.ops.floor_div
|
||||
|
@ -277,6 +279,7 @@ mindspore.ops
|
|||
mindspore.ops.t
|
||||
mindspore.ops.tan
|
||||
mindspore.ops.tanhshrink
|
||||
mindspore.ops.trapz
|
||||
mindspore.ops.true_divide
|
||||
mindspore.ops.trunc
|
||||
mindspore.ops.truncate_div
|
||||
|
@ -365,6 +368,7 @@ Reduction函数
|
|||
mindspore.ops.inner
|
||||
mindspore.ops.inverse
|
||||
mindspore.ops.ger
|
||||
mindspore.ops.kron
|
||||
mindspore.ops.matmul
|
||||
mindspore.ops.matrix_solve
|
||||
mindspore.ops.matrix_exp
|
||||
|
@ -373,6 +377,8 @@ Reduction函数
|
|||
mindspore.ops.matrix_diag_part
|
||||
mindspore.ops.matrix_set_diag
|
||||
mindspore.ops.mm
|
||||
mindspore.ops.mv
|
||||
mindspore.ops.outer
|
||||
mindspore.ops.orgqr
|
||||
mindspore.ops.pinv
|
||||
mindspore.ops.svd
|
||||
|
@ -391,6 +397,8 @@ Reduction函数
|
|||
mindspore.ops.bartlett_window
|
||||
mindspore.ops.blackman_window
|
||||
mindspore.ops.hamming_window
|
||||
mindspore.ops.hann_window
|
||||
mindspore.ops.kaiser_window
|
||||
|
||||
Tensor操作函数
|
||||
----------------
|
||||
|
@ -451,7 +459,9 @@ Array操作
|
|||
|
||||
mindspore.ops.batch_to_space_nd
|
||||
mindspore.ops.bincount
|
||||
mindspore.ops.block_diag
|
||||
mindspore.ops.broadcast_to
|
||||
mindspore.ops.cartesian_prod
|
||||
mindspore.ops.cat
|
||||
mindspore.ops.chunk
|
||||
mindspore.ops.concat
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
mindspore.nn.Identity
|
||||
=======================
|
||||
|
||||
.. py:class:: mindspore.nn.Identity
|
||||
|
||||
返回与输入具有相同shape和值的Tensor。
|
||||
|
||||
输入:
|
||||
- **x** (Tensor) - shape为 :math:`(x_1, x_2, ..., x_R)` 的Tensor。数据类型为Number。
|
||||
|
||||
输出:
|
||||
Tensor,shape和数据类型与 `input_x` 相同, :math:`(x_1, x_2, ..., x_R)` 。
|
||||
|
||||
异常:
|
||||
- **TypeError** - `x` 不是Tensor。
|
|
@ -0,0 +1,41 @@
|
|||
mindspore.nn.PoissonNLLLoss
|
||||
============================
|
||||
|
||||
.. py:class:: class PoissonNLLLoss(log_input=True, full=False, eps=1e-8, reduction='mean')
|
||||
|
||||
计算泊松负对数似然损失。
|
||||
|
||||
损失为:
|
||||
|
||||
.. math::
|
||||
\mathcal{L}_{D} = \sum_{i = 0}^{|D|}\left( x_{i} - y_{i}\ln x_{i} + \ln{y_{i}!} \right)
|
||||
|
||||
其中 :math:`\mathcal{L}_{D}` 为损失值, :math:`y_{i}` 为 `target` , :math:`x_{i}` 为 `x` 。
|
||||
|
||||
如果 `log_input` 为True,使用 :math:`e^{x_{i}} - y_{i} x_{i}` 而不是 :math:`x_{i} - y_{i}\ln x_{i}` 进行计算。
|
||||
计算对数时,`x` 的下界设置为`eps`,以避免数值误差。
|
||||
如果 `full` 为False,则最后一项::math:`\ln{y_{i}!}` 将被省略。否则,最后一项将使用斯特林公式近似:
|
||||
|
||||
.. math::
|
||||
n! \approx \sqrt{2\pi n}\left( \frac{n}{e} \right)^{n}
|
||||
|
||||
.. note::
|
||||
在Ascend下计算负数的对数或大正数的指数将具有与GPU和CPU下不同的返回值和结果范围。
|
||||
|
||||
参数:
|
||||
- **log_input** (bool,可选) - 是否使用对数输入。默认值:True。
|
||||
- **full** (bool,可选) - 是否在损失计算中包括斯特林近似项。默认值:False。
|
||||
- **eps** (float,可选) - 算对数时 `x` 的下界。默认值:1e-8。
|
||||
- **reduction** (str,可选) - 指定要应用于输出的缩减方式,取值为'none'、'mean'或'sum'。默认值:'mean'。
|
||||
|
||||
输入:
|
||||
- **x** (Tensor) - 输入Tensor。shape可以是任意维。
|
||||
- **target** (Tensor) - 标签Tensor,其shape与 `x` 相同。
|
||||
|
||||
输出:
|
||||
Tensor或Scalar,如果 `reduction` 为none',则输出是Tensor,其形状与 `x` 相同。否则,它是Scalar。
|
||||
|
||||
异常:
|
||||
- **TypeError** - `reduction` 不是str类型。
|
||||
- **TypeError** - `x` 或 `target` 都不是Tensor。
|
||||
- **TypeError** - `x` 或 `target` 的数据类型不支持。
|
|
@ -0,0 +1,25 @@
|
|||
mindspore.nn.Unflatten
|
||||
=======================
|
||||
|
||||
.. py:class:: mindspore.nn.Unflatten(axis, unflattened_size)
|
||||
|
||||
根据 `axis` 和 `unflattened_size` 折叠指定维度为给定形状。
|
||||
|
||||
参数:
|
||||
- **axis** (int) - 指定输入Tensor被折叠维度。
|
||||
- **unflattened_size** (Union(tuple[int], list[int])) - 指定维度维度折叠后的新shape,可以为tuple[int]或者list[int]。 `unflattened_size` 中各元素的乘积必须等于input_shape[axis]。
|
||||
|
||||
输入:
|
||||
- **input** (Tensor) - 进行折叠操作的Tensor。
|
||||
|
||||
输出:
|
||||
折叠操作后的Tensor。
|
||||
|
||||
- :math:`out\_depth = ksize\_row * ksize\_col * in\_depth`
|
||||
- :math:`out\_row = (in\_row - (ksize\_row + (ksize\_row - 1) * (rate\_row - 1))) // stride\_row + 1`
|
||||
- :math:`out\_col = (in\_col - (ksize\_col + (ksize\_col - 1) * (rate\_col - 1))) // stride\_col + 1`
|
||||
|
||||
异常:
|
||||
- **TypeError** - `axis` 不是int。
|
||||
- **TypeError** - `unflattened_size` 既不是tuple[int]也不是list[int]。
|
||||
- **TypeError** - `unflattened_size` 中各元素的乘积不等于input_shape[axis]。
|
|
@ -0,0 +1,16 @@
|
|||
mindspore.ops.block_diag
|
||||
=========================
|
||||
|
||||
.. py:function:: mindspore.ops.block_diag(inputs)
|
||||
|
||||
基于输入Tensor创建块对角矩阵。
|
||||
|
||||
参数:
|
||||
- **inputs** (List[Tensor]) - Tensor的维度应该为0、1或2。
|
||||
|
||||
返回:
|
||||
Tensor,二维矩阵。所有输入Tensor按顺序排列,使其左上角和右下角对角线相邻,其他所有元素都置零。
|
||||
|
||||
异常:
|
||||
- **TypeError** - 输入不是Tensor列表。
|
||||
- **ValueError** - 输入Tensor维度不为0、1或2。
|
|
@ -0,0 +1,15 @@
|
|||
mindspore.ops.cartesian_prod
|
||||
=============================
|
||||
|
||||
.. py:function:: mindspore.ops.cartesian_prod(inputs)
|
||||
|
||||
对给定Tensor序列计算Cartesian乘积,类似于Python里的 `itertools.product` 。
|
||||
|
||||
参数:
|
||||
- **inputs** (List[Tensor]) - Tensor序列。
|
||||
|
||||
返回:
|
||||
Tensor,Tensor序列的Cartesian乘积。
|
||||
|
||||
异常:
|
||||
- **TypeError** - 输入不是Tensor类型。
|
|
@ -5,8 +5,10 @@ mindspore.ops.diff
|
|||
|
||||
沿着给定维度计算输入Tensor的n阶前向差分。
|
||||
|
||||
第一阶差分沿着给定轴由如下公式计算::math:`out[i] = a[i+1] - a[i]` ,更高阶差分通过迭代使用 `diff` 计算。
|
||||
|
||||
.. note::
|
||||
- 不支持空Tensor, 如果传入了空Tensor,会出现ValueError。
|
||||
不支持空Tensor, 如果传入了空Tensor,会出现ValueError。
|
||||
|
||||
参数:
|
||||
- **x** (Tensor) - 输入Tensor。x元素的数据类型不支持uint16、uint32 或 uint64。
|
||||
|
@ -16,7 +18,7 @@ mindspore.ops.diff
|
|||
- **append** (Tensor,可选)) - 在计算差分之前,沿 axis 将值添加到 input 或附加到 input。它们的维度必须与输入的维度相同,并且它们的shape必须与输入的shape匹配,但 axis 除外。默认值:None。
|
||||
|
||||
返回:
|
||||
Tensor,输入Tensor差分后的结果。
|
||||
Tensor,输入Tensor差分后的结果。输出的shape除了第 `axis` 维上尺寸缩小 `n` 以外,与 `x` 一致。输出的类型与 `x` 一致。
|
||||
|
||||
异常:
|
||||
- **TypeError** - 如果 `x` 不是Tensor。
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
mindspore.ops.dist
|
||||
====================
|
||||
|
||||
.. py:function:: mindspore.ops.dist(input_x, input_y, p=2)
|
||||
|
||||
计算输入中每对行向量之间的p-范数距离。
|
||||
|
||||
.. note::
|
||||
在MindSpore中只支持计算整数 :math:`p`-norm形式的范数,如果 :math:`p` 不是整数会引发类型错误。
|
||||
|
||||
参数:
|
||||
- **input_x** (Tensor) - 第一个输入Tensor,数据类型需为float16或float32。
|
||||
- **input_y** (float) - 第二个输入Tensor,数据类型需为float1或float32。
|
||||
- **p** (int,可选) - 范数的次数。 `p` 大于或等于0。默认值:2。
|
||||
|
||||
返回:
|
||||
Tensor,具有与 `input_x` 相同的dtype,其shape为::math:`(1)` 。
|
||||
|
||||
异常:
|
||||
- **TypeError** - `input_x` 或 `input_y` 不是Tensor。
|
||||
- **TypeError** - `input_x` 和 `input_y` 数据类型不是float16或float32。
|
||||
- **TypeError** - `p` 不是非负整数。
|
|
@ -0,0 +1,18 @@
|
|||
mindspore.ops.exp2
|
||||
==================
|
||||
|
||||
.. py:function:: mindspore.ops.exp2(x)
|
||||
|
||||
逐元素计算Tensor `x` 以2为底的指数。
|
||||
|
||||
.. math::
|
||||
out_i = 2^{x_i}
|
||||
|
||||
参数:
|
||||
- **x** (Tensor) - 输入Tensor。
|
||||
|
||||
返回:
|
||||
Tensor,具有与 `x` 相同的数据类型和shape。
|
||||
|
||||
异常:
|
||||
- **TypeError** - `x` 不是Tensor。
|
|
@ -0,0 +1,23 @@
|
|||
mindspore.ops.hann_window
|
||||
==========================
|
||||
|
||||
.. py:function:: mindspore.ops.hann_window(window_length, periodic=True)
|
||||
|
||||
生成一个Hann window。
|
||||
|
||||
Hann window定义:
|
||||
|
||||
.. math::
|
||||
w(n) = \frac{1}{2} - \frac{1}{2} \cos\left(\frac{2\pi{n}}{M-1}\right) \qquad 0 \leq n \leq M-1
|
||||
|
||||
参数:
|
||||
- **window_length** (int) - 输出window的大小。
|
||||
- **periodic** (bool, 可选) - 如果为True,则返回周期性window用于进行谱线分析。如果为False,则返回对称的window用于设计滤波器。默认值:True。
|
||||
|
||||
返回:
|
||||
Tensor,一个Hann window。
|
||||
|
||||
异常:
|
||||
- **TypeError** - 如果 `window_length` 不是整数。
|
||||
- **TypeError** - 如果 `periodic` 不是布尔类型。
|
||||
- **ValueError** - 如果 `window_length` 小于零。
|
|
@ -0,0 +1,30 @@
|
|||
mindspore.ops.kaiser_window
|
||||
============================
|
||||
|
||||
.. py:function:: mindspore.ops.kaiser_window(window_length, periodic=True, beta=12)
|
||||
|
||||
生成一个Kaiser window,也叫做Kaiser-Bessel window。
|
||||
|
||||
Kaiser window定义:
|
||||
|
||||
.. math::
|
||||
w(n) = \frac{I_{0}\left( \beta\sqrt{1 - \frac{4n^{2}}{(M - 1)^{2}}} \right)}{I_{0}(\beta)}
|
||||
|
||||
n的范围为
|
||||
|
||||
.. math::
|
||||
- \frac{M - 1}{2} \leq n \leq \frac{M - 1}{2}
|
||||
|
||||
其中 :math:`I_0` 为零阶修正Bessel函数。
|
||||
|
||||
参数:
|
||||
- **window_length** (int) - 输出window的大小。
|
||||
- **periodic** (bool, 可选) - 如果为True,则返回周期性window用于进行谱线分析。如果为False,则返回对称的window用于设计滤波器。默认值:True。
|
||||
- **beta** (int, 可选) - 形状参数,当 `beta` 变大时,窗口就会变窄。默认值:12。
|
||||
返回:
|
||||
Tensor,一个Kaiser window。
|
||||
|
||||
异常:
|
||||
- **TypeError** - 如果 `window_length` 或 `beta` 不是整数。
|
||||
- **TypeError** - 如果 `periodic` 不是布尔类型。
|
||||
- **ValueError** - 如果 `window_length` 小于零。
|
|
@ -0,0 +1,26 @@
|
|||
mindspore.ops.kron
|
||||
==================
|
||||
|
||||
.. py:function:: mindspore.ops.kron(x, y)
|
||||
|
||||
计算 `x` 和 `y` 的Kronecker积::math:`x⊗y` 。
|
||||
如果 `x` 是Tensor :math:`(a_{0}` x :math:`a_{1}` x ... x :math:`a_{n})` , `y` 是Tensor :math:`(b_{0}` x :math:`b_{1}` x ... x :math:`b_{n})` ,计算结果为Tensor :math:`(a_{0}*b_{0}` x :math:`a_{1}*b_{1}` x ... x :math:`a_{n}*b_{n})` ,计算公式如下:
|
||||
|
||||
.. math::
|
||||
(x ⊗ y)_{k_{0},k_{1},...k_{n}} = x_{i_{0},i_{1},...i_{n}} * y_{j_{0},j_{1},...j_{n}},
|
||||
|
||||
其中,对于所有的 0 ≤ `t` ≤ `n`,都有 :math:`k_{t} = i_{t} * b_{t} + j_{t}` 。如果其中一个Tensor维度小于另外一个,则在第一维补维度直到两Tensor维度相同为止。
|
||||
|
||||
.. note::
|
||||
支持实数和复数类型的输入。
|
||||
|
||||
参数:
|
||||
- **x** (Tensor) - 输入Tensor,shape为 :math:`(r0, r1, ... , rN)` 。
|
||||
- **y** (Tensor) - 输入Tensor,shape为 :math:`(s0, s1, ... , sN)` 。
|
||||
|
||||
返回:
|
||||
Tensor,shape为 :math:`(r0 * s0, r1 * s1, ... , rN * sN)` 。
|
||||
|
||||
异常:
|
||||
- **TypeError** - `x` 不是Tensor。
|
||||
- **TypeError** - `y` 不是Tensor。
|
|
@ -0,0 +1,19 @@
|
|||
mindspore.ops.mv
|
||||
=================
|
||||
|
||||
.. py:function:: mindspore.ops.mv(mat, vec)
|
||||
|
||||
实现矩阵 `mat` 和向量 `vec` 相乘。
|
||||
|
||||
如果 `mat` 是shape为 :math:`(N, M)` 的Tensor, `vec` 是长度为 :math:`M` 的一维Tensor,则输出是长度为 :math:`N` 的一维Tensor。
|
||||
|
||||
参数:
|
||||
- **mat** (Tensor) - 输入矩阵,其shape为 :math:`(N, M)` 。
|
||||
- **vec** (Tensor) - 输入向量,其shape为 :math:`(M,)` 。
|
||||
|
||||
返回:
|
||||
Tensor,其shape为 :math:`(N,)` 。
|
||||
|
||||
异常:
|
||||
- **TypeError** - `mat` 或 `vec` 不是Tensor。
|
||||
- **ValueError** - `mat` 不是2维Tensor或 `vec` 不是1维Tensor。
|
|
@ -0,0 +1,20 @@
|
|||
mindspore.ops.outer
|
||||
====================
|
||||
|
||||
.. py:function:: mindspore.ops.outer(x1, x2)
|
||||
|
||||
计算 `x1` 和 `x2` 的外积。如果向量 `x1` 长度为n, `x2` 长度为m,则输出矩阵尺寸为n x m。
|
||||
|
||||
.. note::
|
||||
该函数不支持广播。
|
||||
|
||||
参数:
|
||||
- **x1** (Tensor) - 输入一维向量。
|
||||
- **x2** (Tensor) - 输入一维向量。
|
||||
|
||||
返回:
|
||||
out (Tensor, optional),两个一维向量的外积,是一个2维矩阵,。
|
||||
|
||||
异常:
|
||||
- **TypeError** - 如果 `x1` 或 `x2` 不是Tensor。
|
||||
- **ValueError** - 如果 `x1` 或 `x2` 不是一维Tensor。
|
|
@ -11,7 +11,7 @@ mindspore.ops.remainder
|
|||
out_{i} = input_{i} \text{ % } other_{i}
|
||||
|
||||
.. warning::
|
||||
- 当输入元素超过2048时,可能会有京精度问题。
|
||||
- 当输入元素超过2048时,可能会有精度问题。
|
||||
- 在Ascend和CPU上的计算结果可能不一致。
|
||||
- 如果shape表示为(D1,D2…Dn),那么D1 \ * D2……\ * DN <= 1000000,n <= 8。
|
||||
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
mindspore.ops.trapz
|
||||
====================
|
||||
|
||||
.. py:function:: mindspore.ops.trapz(y, x, dx, dim)
|
||||
|
||||
使用梯形法则沿给定轴对 `y` (x)进行积分。
|
||||
默认情况下,点之间的x轴距离将为1,或者它们可以由数组 `x` 或者标量 `dx` 提供。
|
||||
|
||||
.. math::
|
||||
\mathop{ \int }\nolimits_{{}}^{{}}{y}{ \left( {x} \right) } \text{d} x
|
||||
|
||||
参数:
|
||||
- **y** (Tensor) - 要积分的Tensor。
|
||||
- **x** (Tensor,可选) - 对应于 `y` 值的样本点。如果 `x` 为None,则采样点均匀间隔 `dx` ,默认值:None。如果x不为None,则由 `dim` 指定的轴减去1后,x的形状应与 `y` 相同或者可以广播到 `y` 。
|
||||
- **dx** (float,可选) - 当 `x` 为None时,采样点之间的间距。默认值:1.0。
|
||||
- **dim** (int,可选) - 进行积分的维度。默认值:-1。
|
||||
|
||||
返回:
|
||||
浮点类型Tenor,用梯形规则近似的定积分。如果 `y` 是一维数组,则结果是浮点数。如果 `y` 是n维数组,结果是一个N-1维数组。
|
||||
|
||||
异常:
|
||||
- **RuntimeError** - 如果 `x` 维度为1且x.shape[0]不等于y.shape[dim]。
|
||||
- **ValueError** - 如果 `dim` 不在 :math:`[-y.ndim, y.ndim)` 范围内。
|
||||
- **TypeError** - 如果 `y` 不是Tensor。
|
||||
- **TypeError** - 如果 `x` 不为None的同时不是Tensor。
|
||||
- **TypeError** - 如果 `dx` 不是浮点数。
|
||||
- **TypeError** - 如果 `dim` 不是整数。
|
|
@ -251,6 +251,7 @@ Loss Function
|
|||
mindspore.nn.MultiClassDiceLoss
|
||||
mindspore.nn.MultiLabelSoftMarginLoss
|
||||
mindspore.nn.NLLLoss
|
||||
mindspore.nn.PoissonNLLLoss
|
||||
mindspore.nn.RMSELoss
|
||||
mindspore.nn.SampledSoftmaxLoss
|
||||
mindspore.nn.SmoothL1Loss
|
||||
|
@ -376,6 +377,8 @@ Tools
|
|||
|
||||
mindspore.nn.ChannelShuffle
|
||||
mindspore.nn.Flatten
|
||||
mindspore.nn.Identity
|
||||
mindspore.nn.Unflatten
|
||||
|
||||
Mathematical Operations
|
||||
-----------------------
|
||||
|
|
|
@ -115,6 +115,7 @@ Distance Functions
|
|||
:template: classtemplate.rst
|
||||
|
||||
mindspore.ops.cdist
|
||||
mindspore.ops.dist
|
||||
mindspore.ops.pdist
|
||||
|
||||
Sampling Functions
|
||||
|
@ -219,6 +220,7 @@ Element-wise Operations
|
|||
mindspore.ops.erfc
|
||||
mindspore.ops.erfinv
|
||||
mindspore.ops.exp
|
||||
mindspore.ops.exp2
|
||||
mindspore.ops.expm1
|
||||
mindspore.ops.floor
|
||||
mindspore.ops.floor_div
|
||||
|
@ -277,6 +279,7 @@ Element-wise Operations
|
|||
mindspore.ops.t
|
||||
mindspore.ops.tan
|
||||
mindspore.ops.tanhshrink
|
||||
mindspore.ops.trapz
|
||||
mindspore.ops.true_divide
|
||||
mindspore.ops.trunc
|
||||
mindspore.ops.truncate_div
|
||||
|
@ -365,6 +368,7 @@ Linear Algebraic Functions
|
|||
mindspore.ops.inner
|
||||
mindspore.ops.inverse
|
||||
mindspore.ops.ger
|
||||
mindspore.ops.kron
|
||||
mindspore.ops.matmul
|
||||
mindspore.ops.matrix_solve
|
||||
mindspore.ops.matrix_exp
|
||||
|
@ -373,6 +377,8 @@ Linear Algebraic Functions
|
|||
mindspore.ops.matrix_diag_part
|
||||
mindspore.ops.matrix_set_diag
|
||||
mindspore.ops.mm
|
||||
mindspore.ops.mv
|
||||
mindspore.ops.outer
|
||||
mindspore.ops.orgqr
|
||||
mindspore.ops.pinv
|
||||
mindspore.ops.svd
|
||||
|
@ -391,6 +397,8 @@ Spectral Functions
|
|||
mindspore.ops.bartlett_window
|
||||
mindspore.ops.blackman_window
|
||||
mindspore.ops.hamming_window
|
||||
mindspore.ops.hann_window
|
||||
mindspore.ops.kaiser_window
|
||||
|
||||
Tensor Operation Functions
|
||||
--------------------------
|
||||
|
@ -451,7 +459,9 @@ Array Operation
|
|||
|
||||
mindspore.ops.batch_to_space_nd
|
||||
mindspore.ops.bincount
|
||||
mindspore.ops.block_diag
|
||||
mindspore.ops.broadcast_to
|
||||
mindspore.ops.cartesian_prod
|
||||
mindspore.ops.cat
|
||||
mindspore.ops.chunk
|
||||
mindspore.ops.concat
|
||||
|
|
|
@ -33,7 +33,7 @@ typedef struct {
|
|||
* 1.time_step_: step num only for rnn or lstm model. Default is 1.
|
||||
* 2.max_roi_num_: maximum number of ROI area, which is single picture supports, must be greater than 0.Default is 300.
|
||||
* 3.core_ids_: running kernels' id, support multi-core, separated by commas when setting, such as {0, 1, 2}.
|
||||
* each element must be a integer, wch meet such inequality 0 <= val < 8.
|
||||
* each element must be an integer, wch meet such inequality 0 <= val < 8.
|
||||
* Default is {0}.
|
||||
*/
|
||||
class Flags {
|
||||
|
|
|
@ -1216,7 +1216,7 @@ def _expand_tuple(n_dimensions):
|
|||
for i in m:
|
||||
if not isinstance(i, int) or isinstance(i, bool):
|
||||
raise TypeError(f"When expanding an int number to tuple, "
|
||||
f"the type of element in input tuple must be a integer, but got {type(i)}.")
|
||||
f"the type of element in input tuple must be an integer, but got {type(i)}.")
|
||||
return m
|
||||
|
||||
return convert
|
||||
|
|
|
@ -155,7 +155,7 @@ class SparseTensor(COOTensor_):
|
|||
the SparseTensor, respectively.
|
||||
values (Tensor): A 1-D tensor of any type and shape `[N]`, which
|
||||
supplies the values for each element in `indices`.
|
||||
shape (tuple(int)): A integer tuple of size `ndims`,
|
||||
shape (tuple(int)): An integer tuple of size `ndims`,
|
||||
which specifies the shape of the sparse tensor.
|
||||
|
||||
Returns:
|
||||
|
@ -231,7 +231,7 @@ class COOTensor(COOTensor_):
|
|||
Please make sure that the indices are in range of the given shape.
|
||||
values (Tensor): A 1-D tensor of any type and shape `[N]`, which
|
||||
supplies the values for each element in `indices`.
|
||||
shape (tuple(int)): A integer tuple of size `ndims`,
|
||||
shape (tuple(int)): An integer tuple of size `ndims`,
|
||||
which specifies the dense_shape of the sparse tensor.
|
||||
coo_tensor (COOTensor): A COOTensor object.
|
||||
|
||||
|
|
|
@ -1942,12 +1942,12 @@ class Roll(Cell):
|
|||
class Unflatten(Cell):
|
||||
r"""
|
||||
Summary:
|
||||
Unflattens a tensor dim according to axis and unflattened_size.
|
||||
Unflattens a Tensor dim according to `axis` and `unflattened_size`.
|
||||
|
||||
Args:
|
||||
axis (int): specifies the dimension of the input tensor to be unflattened.
|
||||
unflattened_size (Union(tuple[int], list[int])): is the new shape of the unflattened dimension of
|
||||
the tensor and it can be a tuple of ints or a list of ints. The product of unflattened_size
|
||||
axis (int): specifies the dimension of the input Tensor to be unflattened.
|
||||
unflattened_size (Union(tuple[int], list[int])): the new shape of the unflattened dimension of
|
||||
the Tensor and it can be a tuple of ints or a list of ints. The product of `unflattened_size`
|
||||
must equal to input_shape[axis].
|
||||
|
||||
Inputs:
|
||||
|
@ -1959,7 +1959,7 @@ class Unflatten(Cell):
|
|||
Raises:
|
||||
TypeError: If `axis` is not int.
|
||||
TypeError: If `unflattened_size` is neither tuple of ints nor list of ints.
|
||||
TypeError: If the value specified by `axis` is not equal to product of `unflattened_size`.
|
||||
TypeError: The product of `unflattened_size` does not equal to input_shape[axis].
|
||||
|
||||
Supported Platforms:
|
||||
``Ascend`` ``GPU`` ``CPU``
|
||||
|
|
|
@ -1151,17 +1151,17 @@ class PoissonNLLLoss(LossBase):
|
|||
otherwise the last term will be approximated using Stirling formula:
|
||||
|
||||
.. math::
|
||||
n! \approx \sqrt{2\pi n}\left( \frac{n}{e} \right)^{n}.
|
||||
n! \approx \sqrt{2\pi n}\left( \frac{n}{e} \right)^{n}
|
||||
|
||||
Note:
|
||||
Calculating the logarithm of a negative number or the exponent of a large positive number under Ascend
|
||||
will have a different range of return values and results different from those under GPU and CPU.
|
||||
|
||||
Args:
|
||||
log_input (bool): Whether use log input. Default: True.
|
||||
full (bool): Whether include the Stirling approximation term in the loss calculation. Default: False.
|
||||
eps (float): Lower bound of `x` when calculating logarithms. Default: 1e-8.
|
||||
reduction (str): Apply specific reduction method to the output:
|
||||
log_input (bool, optional): Whether use log input. Default: True.
|
||||
full (bool, optional): Whether include the Stirling approximation term in the loss calculation. Default: False.
|
||||
eps (float, optional): Lower bound of `x` when calculating logarithms. Default: 1e-8.
|
||||
reduction (str, optional): Apply specific reduction method to the output:
|
||||
'none', 'mean', 'sum'. Default: 'mean'.
|
||||
|
||||
Inputs:
|
||||
|
|
|
@ -351,7 +351,6 @@ from .math_func import (
|
|||
combinations,
|
||||
dist,
|
||||
copysign,
|
||||
chain_matmul,
|
||||
hann_window,
|
||||
log2,
|
||||
xlogy,
|
||||
|
@ -382,7 +381,7 @@ from .math_func import (
|
|||
roll,
|
||||
orgqr,
|
||||
sum,
|
||||
matrix_exp
|
||||
matrix_exp,
|
||||
)
|
||||
from .nn_func import (
|
||||
adaptive_avg_pool1d,
|
||||
|
|
|
@ -483,15 +483,20 @@ def bincount(x, weights=None, minlength=0):
|
|||
|
||||
def exp2(x):
|
||||
"""
|
||||
Computes the base two exponential function of input.
|
||||
Computes base two exponential of Tensor `x` element-wise.
|
||||
|
||||
Calculates ``2^x``.
|
||||
.. math::
|
||||
out_i = 2^{x_i}
|
||||
|
||||
Args:
|
||||
x (Tensor): Input tensor.
|
||||
|
||||
Returns:
|
||||
Tensor.
|
||||
Tensor, has the same shape and dtype as the `x`.
|
||||
|
||||
Raises:
|
||||
TypeError: If `x` is not a Tensor.
|
||||
|
||||
|
||||
Supported Platforms:
|
||||
``Ascend`` ``GPU`` ``CPU``
|
||||
|
@ -1455,7 +1460,7 @@ def inplace_index_add(var, indices, updates, axis):
|
|||
The shape must be the same as `var` except the `axis` th dimension.
|
||||
axis (int): The dimension along which to index.
|
||||
|
||||
Outputs:
|
||||
Returns:
|
||||
Tensor, has the same shape and dtype as `var`.
|
||||
|
||||
Raises:
|
||||
|
@ -2189,7 +2194,7 @@ def polar(abs, angle): # pylint: disable=redefined-outer-name
|
|||
:math:`(N,*)`, where :math:`*` means additional dimensions of size less than 8.
|
||||
Must be one of the following types: float32, float64.
|
||||
|
||||
Outputs:
|
||||
Returns:
|
||||
Tensor, has the same shape and data type as `abs`.
|
||||
|
||||
Raises:
|
||||
|
@ -4816,14 +4821,12 @@ def outer(x1, x2):
|
|||
x1 (Tensor): 1-D input vector.
|
||||
x2 (Tensor): 1-D input vector.
|
||||
|
||||
Outputs:
|
||||
out (Tensor, optional) : optional output matrix.
|
||||
Returns:
|
||||
out (Tensor, optional) : 2-D matrix, the outer product of two vectors.
|
||||
|
||||
Raises:
|
||||
TypeError: If `x1` is not a Tensor.
|
||||
TypeError: If `x2` is not a Tensor.
|
||||
ValueError: Expected 1-D input `x1`, but got n-D.
|
||||
ValueError: Expected 1-D input `x2`, but got n-D.
|
||||
TypeError: If `x1` or `x2` is not a Tensor.
|
||||
ValueError: If `x1` or `x2` is not an 1-D Tensor.
|
||||
|
||||
Supported Platforms:
|
||||
``Ascend`` ``GPU`` ``CPU``
|
||||
|
@ -4860,19 +4863,19 @@ def mv(mat, vec):
|
|||
"""
|
||||
Multiplies matrix `mat` and vector `vec`.
|
||||
|
||||
If mat is a :math:`(N, M)` tensor, vec is a 1-D tensor of size :math:`M`, out will be 1-D of size :math:`N`.
|
||||
If `mat` is a Tensor with :math:`(N, M)`, `vec` is a 1-D Tensor of size :math:`M`,
|
||||
out will be 1-D of size :math:`N`.
|
||||
|
||||
Args:
|
||||
mat (Tensor): Input matrix of the tensor. The shape of the tensor is :math:`(N, M)`.
|
||||
vec (Tensor): Input vector of the tensor. The shape of the tensor is :math:`(M,)`.
|
||||
mat (Tensor): Input matrix of shape :math:`(N, M)`.
|
||||
vec (Tensor): Input vector of shape :math:`(M,)`.
|
||||
|
||||
Returns:
|
||||
Tensor, the shape of the output tensor is :math:`(N,)`.
|
||||
Tensor, the shape of the output Tensor is :math:`(N,)`.
|
||||
|
||||
Raises:
|
||||
TypeError: If `mat`, `vec` is not a Tensor.
|
||||
ValueError: If `mat` is not a 2-D Tensor.
|
||||
If `vec` is not a 1-D Tensor.
|
||||
TypeError: If `mat` or `vec` is not a Tensor.
|
||||
ValueError: If `mat` is not a 2-D Tensor or `vec` is not a 1-D Tensor.
|
||||
|
||||
Supported Platforms:
|
||||
``Ascend`` ``GPU`` ``CPU``
|
||||
|
@ -5256,7 +5259,7 @@ def gcd(x1, x2):
|
|||
- **x1** (Tensor) - The first input tensor.
|
||||
- **x2** (Tensor) - The second input tensor.
|
||||
|
||||
Outputs:
|
||||
Returns:
|
||||
Tensor, the shape is the same as the one after broadcasting, and the data type is one
|
||||
with higher digits in the two inputs.
|
||||
|
||||
|
@ -6001,13 +6004,12 @@ def diff(x, n=1, axis=-1, prepend=None, append=None):
|
|||
match `x` except along `axis`. Default: None.
|
||||
|
||||
Returns:
|
||||
Tensor, the n-th differences. The shape of the output is the same as a except along
|
||||
`axis` where the dimension is smaller by `n`. The type of the output is the same
|
||||
as the type of the difference between any two elements of `x`. This is the same
|
||||
as the type of `x` in most cases.
|
||||
Tensor, the n-th differences of input. The shape of the output is the same as `x`
|
||||
except along `axis` where the size is reduced by `n`. The type of the output
|
||||
is the same as `x`.
|
||||
|
||||
Raises:
|
||||
TypeError: If the data type of the elementes in 'x' is uint16, uint32 or uint64.
|
||||
TypeError: If the data type of the elementes in `x` is uint16, uint32 or uint64.
|
||||
TypeError: If `x` is not a tensor.
|
||||
TypeError: If the dimension 'x' is less than 1.
|
||||
RuntimeError: If `n` is not 1.
|
||||
|
@ -6060,7 +6062,7 @@ def tril_indices(row, col, offset=0, dtype=mstype.int64):
|
|||
dtype (:class:`mindspore.dtype`): The specified type of output tensor.
|
||||
An optional data type of `mindspore.int32` and `mindspore.int64`. Default: `mindspore.int32`.
|
||||
|
||||
Outputs:
|
||||
Returns:
|
||||
- **y** (Tensor) - indices of the elements in lower triangular part of matrix. The type is specified by `dtype`.
|
||||
The shape of output is :math:`(2, tril\_size)`, where :math:`tril\_size` is the number of elements in the
|
||||
lower triangular matrix.
|
||||
|
@ -6104,7 +6106,7 @@ def triu_indices(row, col, offset=0, dtype=mstype.int64):
|
|||
dtype (:class:`mindspore.dtype`): The specified type of output tensor.
|
||||
An optional data type of `mindspore.int32` and `mindspore.int64`. Default: `mindspore.int32`.
|
||||
|
||||
Outputs:
|
||||
Returns:
|
||||
- **y** (Tensor) - indices of the elements in upper triangular part of matrix. The type is specified by `dtype`.
|
||||
The shape of output is :math:`(2, triu\_size)`, where :math:`triu\_size` is the number of elements in the
|
||||
upper triangular matrix.
|
||||
|
@ -6465,10 +6467,9 @@ def dist(input_x, input_y, p=2):
|
|||
a type error will be raised if :math:`p` is not an integer.
|
||||
|
||||
Args:
|
||||
input_x (Tensor): The first input tensor. The dtype must be float32 or float16.
|
||||
input_y (Tensor): The second input tensor. The dtype must be float32 or float16.
|
||||
p (int, optional): The order of norm. `p` is greater than or equal to 0.
|
||||
Default: 2. Currently only normalization for integer p-normal form is supported.
|
||||
input_x (Tensor): The first input tensor. The dtype must be float16 or float32.
|
||||
input_y (Tensor): The second input tensor. The dtype must be float16 or float32.
|
||||
p (int, optional): The order of norm. `p` is greater than or equal to 0. Default: 2.
|
||||
|
||||
Returns:
|
||||
Tensor, has the same dtype as `input_x`, which shape is :math:`(1)`.
|
||||
|
@ -6573,139 +6574,14 @@ def copysign(x, other):
|
|||
return P.Select()(less_zero, P.Neg()(pos_tensor), pos_tensor)
|
||||
|
||||
|
||||
def chain_matmul(*inputs):
|
||||
r"""
|
||||
Computes the dot product of two or more 2-D arrays in a single function call, while automatically
|
||||
selecting the fastest evaluation order.
|
||||
multi_dot chains numpy.dot and uses optimal parenthesization of the matrices. For more
|
||||
information, refer to the `wiki page <https://en.wikipedia.org/wiki/Matrix_chain_multiplication>`_.
|
||||
Depending on the shapes of the matrices, this can speed up the multiplication a lot.
|
||||
All the arguments must be 2-D.
|
||||
|
||||
Note:
|
||||
Numpy argument `out` is not supported.
|
||||
|
||||
Args:
|
||||
inputs (List[Tensor]): All the arguments must be 2-D.
|
||||
|
||||
Returns:
|
||||
Tensor, the dot product of the supplied arrays.
|
||||
|
||||
Raises:
|
||||
TypeError: inputs are empty or not tensors.
|
||||
ValueError: inputs are not 2-D.
|
||||
|
||||
Supported Platforms:
|
||||
``Ascend`` ``GPU`` ``CPU``
|
||||
|
||||
Examples:
|
||||
>>> x1 = Tensor(np.ones((2, 2)))
|
||||
>>> x2 = Tensor(np.ones((2, 1)))
|
||||
>>> x3 = Tensor(np.ones((1, 1)))
|
||||
>>> out = ops.chain_matmul(x1, x2, x3)
|
||||
>>> print(out.asnumpy())
|
||||
[[2.]
|
||||
[2.]]
|
||||
>>> x1 = Tensor(np.ones((10000, 100)))
|
||||
>>> x2 = Tensor(np.ones((100, 1000)))
|
||||
>>> x3 = Tensor(np.ones((1000, 5)))
|
||||
>>> x4 = Tensor(np.ones((5, 333)))
|
||||
>>> out = ops.chain_matmul(x1, x2, x3, x4)
|
||||
>>> print(out.asnumpy())
|
||||
[[500000. 500000. 500000. ... 500000. 500000. 500000.]
|
||||
[500000. 500000. 500000. ... 500000. 500000. 500000.]
|
||||
[500000. 500000. 500000. ... 500000. 500000. 500000.]
|
||||
...
|
||||
[500000. 500000. 500000. ... 500000. 500000. 500000.]
|
||||
[500000. 500000. 500000. ... 500000. 500000. 500000.]
|
||||
[500000. 500000. 500000. ... 500000. 500000. 500000.]]
|
||||
"""
|
||||
|
||||
def _min_cost_chain_matmul(dims):
|
||||
"""
|
||||
Returns indices of splits that has the minimal cost for matmul.
|
||||
s[i, j] holds the index of the split with minimal cost for
|
||||
arrays[i, i + 1, ... j]
|
||||
"""
|
||||
dims = tuple(dims)
|
||||
n = len(dims) - 1
|
||||
m = [[0] * n for _ in range(n)]
|
||||
s = [[0] * n for _ in range(n)]
|
||||
for pos in range(1, n):
|
||||
for i in range(n - pos):
|
||||
j = i + pos
|
||||
m[i][j] = float("inf")
|
||||
for k in range(i, j):
|
||||
cost = m[i][k] + m[k + 1][j]
|
||||
cost = cost + dims[i] * dims[k + 1] * dims[j + 1]
|
||||
if cost < m[i][j]:
|
||||
m[i][j] = cost
|
||||
s[i][j] = k
|
||||
return s
|
||||
|
||||
def _get_dims(shapes):
|
||||
"""
|
||||
Returns the chain of the dimensions in arrays.
|
||||
dims[i] == arrays[i - 1].shape[1] == arrays[i].shape[0]
|
||||
"""
|
||||
shapes = tuple(shapes)
|
||||
dims = tuple(map(lambda a: a[0], shapes))
|
||||
return dims + (shapes[-1][1],)
|
||||
|
||||
def _multi_dot(arrays, i, j, order):
|
||||
"""Computes multi dot recursively using minimal cost."""
|
||||
if i == j:
|
||||
return arrays[i]
|
||||
return matmul(
|
||||
_multi_dot(arrays, i, order[i][j], order),
|
||||
_multi_dot(arrays, order[i][j] + 1, j, order),
|
||||
)
|
||||
|
||||
if not inputs:
|
||||
raise TypeError(f"For 'chain_matmul', 'inputs' can not be empty, but got {inputs}")
|
||||
for tensor in inputs:
|
||||
if not isinstance(tensor, Tensor):
|
||||
msg = "For 'chain_matmul', each element of 'inputs' must be a tensor, but got " + f"{type(tensor)}"
|
||||
raise TypeError(msg)
|
||||
if P.Rank()(tensor) != 2:
|
||||
raise ValueError(
|
||||
"For 'chain_matmul', the dimension of each elements in 'inputs' must be 2, but got "
|
||||
f"{P.Rank()(tensor)}"
|
||||
)
|
||||
if len(inputs) == 2:
|
||||
return matmul(inputs[0], inputs[1])
|
||||
|
||||
shape_out = ()
|
||||
arrs = []
|
||||
for arr in inputs:
|
||||
arrs.append(arr)
|
||||
|
||||
shape_out += (P.Shape()(arrs[0])[0],)
|
||||
shape_out += (P.Shape()(arrs[-1])[1],)
|
||||
|
||||
shapes = []
|
||||
for arr in arrs:
|
||||
shapes.append(P.Shape()(arr))
|
||||
last_shape = shapes[0][0]
|
||||
for shape in shapes:
|
||||
if last_shape != shape[0]:
|
||||
raise ValueError(f"For 'chain_matmul', shapes of each element of 'inputs' must be aligned")
|
||||
last_shape = shape[1]
|
||||
dims = _get_dims(shapes)
|
||||
order = _min_cost_chain_matmul(dims)
|
||||
res = _multi_dot(arrs, 0, len(arrs) - 1, order)
|
||||
return P.Reshape()(res, shape_out)
|
||||
|
||||
|
||||
def hann_window(window_length, periodic=True):
|
||||
r"""
|
||||
Generates Hann Window. It is a window that approximates the prolate sphere,
|
||||
for which the ratio of the main sphere energy to the sidelobe energy is maximum.
|
||||
Generates a Hann Window.
|
||||
|
||||
The Hann window is defined as
|
||||
|
||||
.. math::
|
||||
w(n) = \frac{1}{2} - \frac{1}{2} \cos\left(\frac{2\pi{n}}{M-1}\right) \qquad 0 \leq n \leq M-1.
|
||||
w(n) = \frac{1}{2} - \frac{1}{2} \cos\left(\frac{2\pi{n}}{M-1}\right) \qquad 0 \leq n \leq M-1
|
||||
|
||||
Args:
|
||||
window_length (int): Length of window.
|
||||
|
@ -6716,9 +6592,9 @@ def hann_window(window_length, periodic=True):
|
|||
Tensor, a Hann window.
|
||||
|
||||
Raises:
|
||||
TypeError: If `window_length` is not a integer.
|
||||
ValueError: If `window_length` is negative.
|
||||
TypeError: If `window_length` is not an integer.
|
||||
TypeError: If `periodic` is not a variable of Boolean type.
|
||||
ValueError: If `window_length` is negative.
|
||||
|
||||
Supported Platforms:
|
||||
``Ascend`` ``GPU`` ``CPU``
|
||||
|
@ -7611,9 +7487,7 @@ def gumbel_softmax(logits, tau=1, hard=False, dim=-1):
|
|||
|
||||
def kaiser_window(window_length, periodic=True, beta=12.0):
|
||||
r"""
|
||||
Generates a Kaiser window.
|
||||
It is also known as the Kaiser-Bessel window, which is an approximate window of the prolate sphere.
|
||||
The ratio of the main sphere energy to the side wave energy is maximum for it.
|
||||
Generates a Kaiser window, which is also known as the Kaiser-Bessel window.
|
||||
|
||||
The Kaiser window is defined as
|
||||
|
||||
|
@ -7631,16 +7505,15 @@ def kaiser_window(window_length, periodic=True, beta=12.0):
|
|||
window_length (int): Length of window.
|
||||
periodic (bool, optional): When set to True, generates a periodic window for spectral analysis.
|
||||
When set to False, generates a symmetric window for filter design. Default: True.
|
||||
beta (float, optional): Shape parameter, determines trade-off between main-lobe width and side lobe level.
|
||||
When `beta` gets large, the window narrows. Default: 12.0.
|
||||
beta (float, optional): Shape parameter, when `beta` gets large, the window narrows. Default: 12.0.
|
||||
|
||||
Returns:
|
||||
Tensor, a Kaiser window.
|
||||
|
||||
Raises:
|
||||
TypeError: If `window_length` is not a integer.
|
||||
ValueError: If `window_length` is negative.
|
||||
TypeError: If `window_length` or `beta` is not an integer.
|
||||
TypeError: If `periodic` is not a variable of Boolean type.
|
||||
ValueError: If `window_length` is negative.
|
||||
|
||||
Supported Platforms:
|
||||
``Ascend`` ``GPU`` ``CPU``
|
||||
|
@ -8512,32 +8385,28 @@ def kron(x, y):
|
|||
"""
|
||||
Computes the Kronecker product, denoted by ⊗, of `x` and `y`.
|
||||
|
||||
If `x` is a :math:`(a_{0}` x :math:`a_{1}` x ... x :math:`a_{n})` tensor
|
||||
and `y` is a :math:`(b_{0}` x :math:`b_{1}` x ... x :math:`b_{n})` tensor,
|
||||
If `x` is a :math:`(a_{0}` x :math:`a_{1}` x ... x :math:`a_{n})` Tensor
|
||||
and `y` is a :math:`(b_{0}` x :math:`b_{1}` x ... x :math:`b_{n})` Tensor,
|
||||
the result will be a :math:`(a_{0}*b_{0}` x :math:`a_{1}*b_{1}` x ... x :math:`a_{n}*b_{n})`
|
||||
tensor with the following entries:
|
||||
Tensor with the following entries:
|
||||
|
||||
.. math::
|
||||
(x ⊗ y)_{k_{0},k_{1},...k_{n}} =
|
||||
x_{i_{0},i_{1},...i_{n}} * y_{j_{0},j_{1},...j_{n}},
|
||||
|
||||
where :math:`k_{t} = i_{t} * b_{t} + j_{t}` for 0 ≤ `t` ≤ `n`. If one
|
||||
tensor has fewer dimensions than the other it is unsqueezed
|
||||
Tensor has fewer dimensions than the other it is unsqueezed
|
||||
until it has the same number of dimensions.
|
||||
|
||||
Note:
|
||||
Supports real-valued and complex-valued inputs.
|
||||
This function generalizes the typical definition of the Kronecker product
|
||||
for two matrices to two tensors, as described above.
|
||||
When x is a (m x n) matrix and y is a (p x q) matrix, the result
|
||||
be a (p * m x q * n) block matrix.
|
||||
|
||||
Args:
|
||||
x (Tensor): Input tensor, has the shape (r0, r1, ... , rN).
|
||||
y (Tensor): Input tensor, has the shape (s0, s1, ... , sN).
|
||||
x (Tensor): Input Tensor, has the shape :math:`(r0, r1, ... , rN)`.
|
||||
y (Tensor): Input Tensor, has the shape :math:`(s0, s1, ... , sN)`.
|
||||
|
||||
Returns:
|
||||
Tensor, has the shape (r0 * s0, r1 * s1, ... , rN * sN).
|
||||
Tensor, has the shape :math:`(r0 * s0, r1 * s1, ... , rN * sN)`.
|
||||
|
||||
Raises:
|
||||
TypeError: If `x` is not a Tensor.
|
||||
|
@ -8955,10 +8824,9 @@ def select_(feat, dim, index):
|
|||
|
||||
def trapz(y, x=None, dx=1.0, dim=-1):
|
||||
r"""
|
||||
Computes the trapezoidal rule along dim.
|
||||
|
||||
Integrates `y` (x) along given dim. By default x-dim distances between points will be 1.0,
|
||||
alternatively they can be provided with x array or with dx scalar.
|
||||
Integrates `y` (x) along given dim using trapezoidal rule.
|
||||
By default x-dim distances between points will be 1.0,
|
||||
alternatively they can be provided with `x` array or with `dx` scalar.
|
||||
|
||||
.. math::
|
||||
|
||||
|
@ -8967,24 +8835,24 @@ def trapz(y, x=None, dx=1.0, dim=-1):
|
|||
Args:
|
||||
y (Tensor): Input tensor to integrate.
|
||||
x (Tensor, optional): The sample points corresponding to the `y` values. If `x` is None,
|
||||
the sample points are assumed to be evenly spaced `dx` apart. The default is None.
|
||||
If x is not None, after subtracting 1 from the axis specified by dim, the shape of x should be same
|
||||
or can be broadcast to y.
|
||||
dx (float, optional): The spacing between sample points when `x` is None. The default is 1.0.
|
||||
dim (int, optional): The dim along which to integrate. Defaults to -1.
|
||||
the sample points are assumed to be evenly spaced `dx` apart. Default: None.
|
||||
If `x` is not None, after subtracting 1 from the axis specified by `dim`, the shape of `x`
|
||||
should be same as `y` or can broadcast to `y`.
|
||||
dx (float, optional): The spacing between sample points when `x` is None. Default: 1.0.
|
||||
dim (int, optional): The dim along which to integrate. Default: -1.
|
||||
|
||||
Returns:
|
||||
Tensor of float, definite integral as approximated by trapezoidal rule.
|
||||
If y is a one-dimensional array, the result is a floating-point number. If y is an n-dimensional array,
|
||||
the result is an N-1-dimensional array because the dimension associated with the axis has been deleted.
|
||||
If `y` is a one-dimensional array, the result is a floating-point number. If `y` is
|
||||
an n-dimensional array, the result is an N-1 dimensional array.
|
||||
|
||||
Raises:
|
||||
ValueError: If dim is out of range of ``[-y.ndim, y.ndim)``.
|
||||
RuntimeError: If x's ndim is 1, and x's shape[0] is not equal to y's shape[dim].
|
||||
TypeError: If y is not a Tensor.
|
||||
TypeError: If x is not None and is not a Tensor.
|
||||
TypeError: If dx is not a float number.
|
||||
TypeError: If dim is not a Integer.
|
||||
RuntimeError: If dim of `x` is 1, and x.shape[0] is not equal to y.shape[dim].
|
||||
ValueError: If `dim` is out of range of :math:`[-y.ndim, y.ndim)`.
|
||||
TypeError: If `y` is not a Tensor.
|
||||
TypeError: If `x` is not None and is not a Tensor.
|
||||
TypeError: If `dx` is not a float number.
|
||||
TypeError: If `dim` is not a Integer.
|
||||
|
||||
Supported Platforms:
|
||||
``Ascend`` ``GPU`` ``CPU``
|
||||
|
@ -10249,7 +10117,6 @@ __all__ = [
|
|||
'combinations',
|
||||
'dist',
|
||||
'copysign',
|
||||
'chain_matmul',
|
||||
'hann_window',
|
||||
'log2',
|
||||
'slogdet',
|
||||
|
@ -10289,6 +10156,6 @@ __all__ = [
|
|||
'roll',
|
||||
'sum',
|
||||
'matrix_exp',
|
||||
'orgqr'
|
||||
'orgqr',
|
||||
]
|
||||
__all__.sort()
|
||||
|
|
|
@ -81,7 +81,7 @@ def bartlett_window(window_length, periodic=True, *, dtype=None):
|
|||
r"""
|
||||
Bartlett window function.
|
||||
|
||||
The input `window_length` is a tensor that datatype must be a integer, which controlling the returned window size.
|
||||
The input `window_length` is a tensor that datatype must be an integer, which controlling the returned window size.
|
||||
In particular, if `window_length` = 1, the returned window contains a single value 1.
|
||||
|
||||
Attr `periodic` determines whether the returned window trims off the last duplicate value from the symmetric
|
||||
|
|
|
@ -7170,7 +7170,7 @@ class FFTWithSize(Primitive):
|
|||
ValueError: If norm is none of "backward", "forward" or "ortho".
|
||||
|
||||
Supported Platforms:
|
||||
``CPU``
|
||||
``GPU`` ``CPU``
|
||||
|
||||
Examples:
|
||||
>>> # case FFT: signal_ndim: 1, inverse: False, real: False.
|
||||
|
|
|
@ -203,7 +203,7 @@ def shard(fn, in_strategy, out_strategy=None, parameter_plan=None, device="Ascen
|
|||
- If any key in `parameter_plan` is not a str.
|
||||
- If any value in `parameter_plan` is not a tuple.
|
||||
- If `device` is not a str.
|
||||
- If `level` is not a integer.
|
||||
- If `level` is not an integer.
|
||||
|
||||
Supported Platforms:
|
||||
``Ascend`` ``GPU``
|
||||
|
|
|
@ -1174,7 +1174,7 @@ class Model:
|
|||
_device_number_check(self._parallel_mode, self._device_number)
|
||||
|
||||
if not isinstance(valid_frequency, (int, list)):
|
||||
raise TypeError(f"For 'Model.fit', the type of 'valid_frequency' must be a list or a integer, but got "
|
||||
raise TypeError(f"For 'Model.fit', the type of 'valid_frequency' must be a list or an integer, but got "
|
||||
f"type {type(valid_frequency)}.")
|
||||
|
||||
if valid_dataset and not self._metric_fns:
|
||||
|
|
|
@ -522,15 +522,6 @@ class CopysignFunc(nn.Cell):
|
|||
return self.copysign(x, other)
|
||||
|
||||
|
||||
class ChainMatmulFunc(nn.Cell):
|
||||
def __init__(self):
|
||||
super(ChainMatmulFunc, self).__init__()
|
||||
self.chain_matmul = ops.chain_matmul
|
||||
|
||||
def construct(self, x1, x2, x3):
|
||||
return self.chain_matmul(x1, x2, x3)
|
||||
|
||||
|
||||
class HannWindowFunc(nn.Cell):
|
||||
def __init__(self):
|
||||
super(HannWindowFunc, self).__init__()
|
||||
|
@ -923,12 +914,6 @@ test_case_math_ops = [
|
|||
'desc_inputs': [Tensor(np.array([[0.3, -0.7], [0.5, 0.5]])),
|
||||
Tensor(np.array([[-0.4, 0.6], [0.4, -0.6]]))]
|
||||
}),
|
||||
('ChainMatmul', {
|
||||
'block': ChainMatmulFunc(),
|
||||
'desc_inputs': [Tensor(np.array([[1, 1], [1, 1]]), ms.float64),
|
||||
Tensor(np.array([[1], [1]]), ms.float64),
|
||||
Tensor(np.array([[1]]), ms.float64)]
|
||||
}),
|
||||
('HannWindow', {
|
||||
'block': HannWindowFunc(),
|
||||
'desc_inputs': [5]
|
||||
|
|
Loading…
Reference in New Issue