forked from OSSInnovation/mindspore
update document and example of MatrixInverse
This commit is contained in:
parent
a691eeb645
commit
6df0d60b92
|
@ -4491,29 +4491,33 @@ class MatrixInverse(PrimitiveWithInfer):
|
||||||
adjoint (bool) : An optional bool. Default: False.
|
adjoint (bool) : An optional bool. Default: False.
|
||||||
|
|
||||||
Inputs:
|
Inputs:
|
||||||
- **x** (Tensor) - A matrix to be calculated.
|
- **x** (Tensor) - A matrix to be calculated. The matrix must be at least two dimensions, and the last two
|
||||||
types: float32, double.
|
dimensions must be the same size. types: float32, float64.
|
||||||
|
|
||||||
Outputs:
|
Outputs:
|
||||||
Tensor, has the same type and shape as input `x`.
|
Tensor, has the same type and shape as input `x`.
|
||||||
|
|
||||||
Raises:
|
Raises:
|
||||||
TypeError: If `adjoint` is not a bool.
|
TypeError: If `adjoint` is not a bool.
|
||||||
TypeError: If dtype of `x` is neither float32 nor double.
|
TypeError: If dtype of `x` is neither float32 nor float64.
|
||||||
|
ValueError: If the last two dimensions of `x` is not same size.
|
||||||
|
ValueError: If the dimension of `x` is less than 2.
|
||||||
|
|
||||||
Supported Platforms:
|
Supported Platforms:
|
||||||
``GPU``
|
``GPU``
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
>>> mindspore.set_seed(1)
|
>>> x = Tensor(np.array([[[-0.710504 , -1.1207525],
|
||||||
>>> x = Tensor(np.random.uniform(-2, 2, (2, 2, 2)), mindspore.float32)
|
... [-1.7651395 , -1.7576632]],
|
||||||
>>> matrix_inverse = P.MatrixInverse(adjoint=False)
|
... [[ 0.52412605, 1.9070215],
|
||||||
|
... [ 1.3384849 , 1.4274558]]]), mindspore.float32)
|
||||||
|
>>> matrix_inverse = MatrixInverse(adjoint=False)
|
||||||
>>> output = matrix_inverse(x)
|
>>> output = matrix_inverse(x)
|
||||||
>>> print(output)
|
>>> print(output)
|
||||||
[[[-0.39052644 -0.43528939]
|
[[[ 2.408438 -1.535711 ]
|
||||||
[ 0.98761106 -0.16393748]]
|
[-2.4190936 0.97356814]]
|
||||||
[[ 0.52641493 -1.3895369 ]
|
[[-0.79111797 1.0569006 ]
|
||||||
[-1.0693996 1.2040523 ]]]
|
[ 0.74180895 -0.2904787 ]]]
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@prim_attr_register
|
@prim_attr_register
|
||||||
|
|
|
@ -2755,8 +2755,8 @@ class ApplyRMSProp(PrimitiveWithInfer):
|
||||||
|
|
||||||
.. math::
|
.. math::
|
||||||
\begin{array}{ll} \\
|
\begin{array}{ll} \\
|
||||||
s_{t} = \\rho s_{t-1} + (1 - \\rho)(\\nabla Q_{i}(w))^2 \\
|
s_{t} = \rho s_{t-1} + (1 - \rho)(\nabla Q_{i}(w))^2 \\
|
||||||
m_{t} = \\beta m_{t-1} + \\frac{\\eta} {\\sqrt{s_{t} + \\epsilon}} \\nabla Q_{i}(w) \\
|
m_{t} = \beta m_{t-1} + \frac{\eta} {\sqrt{s_{t} + \epsilon}} \nabla Q_{i}(w) \\
|
||||||
w = w - m_{t}
|
w = w - m_{t}
|
||||||
\end{array}
|
\end{array}
|
||||||
|
|
||||||
|
@ -2850,12 +2850,12 @@ class ApplyCenteredRMSProp(PrimitiveWithInfer):
|
||||||
The updating formulas of ApplyCenteredRMSProp algorithm are as follows,
|
The updating formulas of ApplyCenteredRMSProp algorithm are as follows,
|
||||||
|
|
||||||
.. math::
|
.. math::
|
||||||
/begin{array}{ll} \\
|
\begin{array}{ll} \\
|
||||||
g_{t} = \\rho g_{t-1} + (1 - \\rho)\\nabla Q_{i}(w) \\
|
g_{t} = \rho g_{t-1} + (1 - \rho)\nabla Q_{i}(w) \\
|
||||||
s_{t} = \\rho s_{t-1} + (1 - \\rho)(\\nabla Q_{i}(w))^2 \\
|
s_{t} = \rho s_{t-1} + (1 - \rho)(\nabla Q_{i}(w))^2 \\
|
||||||
m_{t} = \\beta m_{t-1} + \\frac{\\eta} {\\sqrt{s_{t} - g_{t}^2 + \\epsilon}} \\nabla Q_{i}(w) \\
|
m_{t} = \beta m_{t-1} + \frac{\eta} {\sqrt{s_{t} - g_{t}^2 + \epsilon}} \nabla Q_{i}(w) \\
|
||||||
w = w - m_{t}
|
w = w - m_{t}
|
||||||
/end{array}
|
\end{array}
|
||||||
|
|
||||||
where :math:`w` represents `var`, which will be updated.
|
where :math:`w` represents `var`, which will be updated.
|
||||||
:math:`g_{t}` represents `mean_gradient`, :math:`g_{t-1}` is the last momentent of :math:`g_{t}`.
|
:math:`g_{t}` represents `mean_gradient`, :math:`g_{t-1}` is the last momentent of :math:`g_{t}`.
|
||||||
|
|
Loading…
Reference in New Issue