From 60c64eb954c172b43d49f8ff120281232b8d1655 Mon Sep 17 00:00:00 2001 From: zhujingxuan Date: Thu, 16 Dec 2021 20:01:55 +0800 Subject: [PATCH] fix doc string --- mindspore/python/mindspore/scipy/linalg.py | 32 +++++++++---------- .../python/mindspore/scipy/sparse/linalg.py | 18 +++++++---- 2 files changed, 27 insertions(+), 23 deletions(-) diff --git a/mindspore/python/mindspore/scipy/linalg.py b/mindspore/python/mindspore/scipy/linalg.py index fdd6bdfdc78..6b45aad1594 100755 --- a/mindspore/python/mindspore/scipy/linalg.py +++ b/mindspore/python/mindspore/scipy/linalg.py @@ -116,8 +116,8 @@ def solve_triangular(A, b, trans=0, lower=False, unit_diagonal=False, Returns: Tensor of shape :math:`(M,)` or :math:`(M, N)`, - which is the solution to the system :math:`A x = b`. - Shape of :math:`x` matches :math:`b`. + which is the solution to the system :math:`A x = b`. + Shape of :math:`x` matches :math:`b`. Raises: LinAlgError: If :math:`A` is singular @@ -213,9 +213,9 @@ def cho_factor(a, lower=False, overwrite_a=False, check_finite=True): (crashes, non-termination) if the inputs do contain infinities or NaNs. Returns: - Tensor, Matrix whose upper or lower triangle contains the Cholesky factor of `a`. - Other parts of the matrix contain random data. - bool, Flag indicating whether the factor is in the lower or upper triangle + - Tensor, Matrix whose upper or lower triangle contains the Cholesky factor of `a`. + Other parts of the matrix contain random data. + - bool, Flag indicating whether the factor is in the lower or upper triangle Raises: LinAlgError: Raised if decomposition fails. @@ -357,9 +357,9 @@ def eigh(a, b=None, lower=True, eigvals_only=False, overwrite_a=False, and eigenvectors are returned. Returns: - Tensor with shape (N,), The N (1<=N<=M) selected eigenvalues, in ascending order, - each repeated according to its multiplicity. - Tensor with shape (M, N), (if ``eigvals_only == False``) + - Tensor with shape (N,), The N (1<=N<=M) selected eigenvalues, in ascending order, + each repeated according to its multiplicity. + - Tensor with shape (M, N), (if ``eigvals_only == False``) Raises: LinAlgError: If eigenvalue computation does not converge, an error occurred, or b matrix is not @@ -457,9 +457,9 @@ def lu_factor(a, overwrite_a=False, check_finite=True): Returns: Tensor, a square matrix of (N, N) containing U in its upper triangle, and L in its lower triangle. - The unit diagonal elements of L are not stored. + The unit diagonal elements of L are not stored. Tensor, (N,) Pivot indices representing the permutation matrix P: - row i of matrix was interchanged with row piv[i]. + row i of matrix was interchanged with row piv[i]. Supported Platforms: ``CPU`` ``GPU`` @@ -506,16 +506,14 @@ def lu(a, permute_l=False, overwrite_a=False, check_finite=True): Returns: **(If permute_l == False)** - Tensor, (M, M) Permutation matrix - Tensor, (M, K) Lower triangular or trapezoidal matrix with unit diagonal. - K = min(M, N) - Tensor, (K, N) Upper triangular or trapezoidal matrix + - Tensor, (M, M) Permutation matrix + - Tensor, (M, K) Lower triangular or trapezoidal matrix with unit diagonal. K = min(M, N) + - Tensor, (K, N) Upper triangular or trapezoidal matrix **(If permute_l == True)** - Tensor, (M, K) Permuted L matrix. - K = min(M, N) - Tensor, (K, N) Upper triangular or trapezoidal matrix + - Tensor, (M, K) Permuted L matrix. K = min(M, N) + - Tensor, (K, N) Upper triangular or trapezoidal matrix Supported Platforms: ``CPU`` ``GPU`` diff --git a/mindspore/python/mindspore/scipy/sparse/linalg.py b/mindspore/python/mindspore/scipy/sparse/linalg.py index e31d1e3a1be..f5eeede97a5 100644 --- a/mindspore/python/mindspore/scipy/sparse/linalg.py +++ b/mindspore/python/mindspore/scipy/sparse/linalg.py @@ -187,6 +187,10 @@ def gmres(A, b, x0=None, *, tol=1e-5, atol=0.0, restart=20, maxiter=None, need not have any particular special properties, such as symmetry. However, convergence is often slow for nearly symmetric operators. + Note: + In the future, MindSpore will report the number of iterations when convergence + is not achieved, like SciPy. Currently it is None, as a Placeholder. + Args: A (Tensor or function): 2D Tensor or function that calculates the linear map (matrix-vector product) ``Ax`` when called like ``A(x)``. @@ -225,9 +229,8 @@ def gmres(A, b, x0=None, *, tol=1e-5, atol=0.0, restart=20, maxiter=None, early termination, but has much less overhead on GPUs. Returns: - Tensor, The converged solution. Has the same structure as ``b``. - None, Placeholder for convergence information. In the future, MindSpore - will report the number of iterations when convergence is not achieved, like SciPy. + - Tensor, The converged solution. Has the same structure as ``b``. + - None, Placeholder for convergence information. Supported Platforms: ``CPU`` ``GPU`` @@ -324,6 +327,10 @@ def cg(A, b, x0=None, *, tol=1e-5, atol=0.0, maxiter=None, M=None): another ``cg`` solve, rather than by differentiating *through* the solver. They will be accurate only if both solves converge. + Note: + In the future, MindSpore will report the number of iterations when convergence + is not achieved, like SciPy. Currently it is None, as a Placeholder. + Args: A (Tensor or function): 2D Tensor or function that calculates the linear map (matrix-vector product) ``Ax`` when called like ``A(x)``. @@ -342,9 +349,8 @@ def cg(A, b, x0=None, *, tol=1e-5, atol=0.0, maxiter=None, M=None): to reach a given error tolerance. Returns: - Tensor, The converged solution. Has the same structure as ``b``. - None, Placeholder for convergence information. In the future, MindSpore will report - the number of iterations when convergence is not achieved, like SciPy. + - Tensor, The converged solution. Has the same structure as ``b``. + - None, Placeholder for convergence information. Supported Platforms: ``CPU`` ``GPU``