fix docstring errors

pull/13175/head
wangrao 4 years ago
parent 0f55faf6e6
commit a6a25904df

@ -833,6 +833,8 @@ class MatMul(Cell):
r"""
Multiplies matrix `x1` by matrix `x2`.
nn.MatMul will be deprecated in future versions. Please use ops.matmul instead.
- If both x1 and x2 are 1-dimensional, the dot product is returned.
- If the dimensions of x1 and x2 are all not greater than 2, the matrix-matrix product will be returned. Note if
one of 'x1' and 'x2' is 1-dimensional, the argument will first be expanded to 2 dimension. After the matrix

@ -688,6 +688,7 @@ def empty(shape, dtype=mstype.float32):
>>> import mindspore.numpy as np
>>> output = np.empty((2, 3))
>>> print(output)
# result may vary
Tensor(shape=[2, 3], dtype=Float32, value=
<uninitialized>)
"""
@ -756,9 +757,10 @@ def empty_like(prototype, dtype=None, shape=None):
Examples:
>>> import mindspore.numpy as np
>>> a = [[(1, 2)], onp.ones((1, 2)), [[2, 3]], onp.ones((1, 2))]
>>> a = [[(1, 2)], np.ones((1, 2)), [[2, 3]], np.ones((1, 2))]
>>> output = np.empty_like(a)
>>> print(output)
# result may vary
Tensor(shape=[4, 1, 2], dtype=Float32, value=
<uninitialized>)
"""
@ -869,7 +871,7 @@ def full_like(a, fill_value, dtype=None, shape=None):
Examples:
>>> import mindspore.numpy as np
>>> a = [[(1, 2)], onp.ones((1, 2)), [[2, 3]], onp.ones((1, 2))]
>>> a = [[(1, 2)], np.ones((1, 2)), [[2, 3]], np.ones((1, 2))]
>>> output = np.full_like(a, 0.5)
>>> print(output)
[[[0.5 0.5]]
@ -1028,6 +1030,7 @@ def diagonal(a, offset=0, axis1=0, axis2=1):
``Ascend`` ``GPU`` ``CPU``
Examples:
>>> import mindspore.numpy as np
>>> a = np.arange(4).reshape(2,2)
>>> print(a)
[[0 1]
@ -1136,6 +1139,7 @@ def trace(a, offset=0, axis1=0, axis2=1, dtype=None):
``Ascend`` ``GPU`` ``CPU``
Examples:
>>> import mindspore.numpy as np
>>> output = np.trace(np.eye(3))
>>> print(output)
3.0
@ -1216,6 +1220,7 @@ def meshgrid(*xi, sparse=False, indexing='xy'):
``Ascend`` ``GPU`` ``CPU``
Examples:
>>> import mindspore.numpy as np
>>> x = np.linspace(0, 1, 3)
>>> y = np.linspace(0, 1, 2)
>>> xv, yv = np.meshgrid(x, y)
@ -1439,6 +1444,7 @@ def diag(v, k=0):
``Ascend`` ``GPU`` ``CPU``
Examples:
>>> import mindspore.numpy as np
>>> x = np.arange(9).reshape((3,3))
>>> print(x)
[[0 1 2]
@ -1505,6 +1511,7 @@ def diagflat(v, k=0):
``Ascend`` ``GPU`` ``CPU``
Examples:
>>> import mindspore.numpy as np
>>> output = np.diagflat(np.asarray([[1,2], [3,4]]))
>>> print(output)
[[1 0 0 0]
@ -1564,6 +1571,7 @@ def diag_indices(n, ndim=2):
``Ascend`` ``GPU`` ``CPU``
Examples:
>>> import mindspore.numpy as np
>>> output = np.diag_indices(5, 3)
>>> print(output)
(Tensor(shape=[5], dtype=Int32, value= [0, 1, 2, 3, 4]),
@ -1605,6 +1613,7 @@ def ix_(*args):
``Ascend`` ``GPU`` ``CPU``
Examples:
>>> import mindspore.numpy as np
>>> ixgrid = np.ix_(np.array([0, 1]), np.array([2, 4]))
>>> print(ixgrid)
[Tensor(shape=[2, 1], dtype=Int32, value=

@ -495,7 +495,7 @@ def append(arr, values, axis=None):
>>> a = np.ones((2, 3))
>>> b = np.ones((2, 1))
>>> print(np.append(a, b, axis=1).shape)
>>> (2, 4)
(2, 4)
"""
_check_input_tensor(arr)
_check_input_tensor(values)
@ -1186,6 +1186,7 @@ def moveaxis(a, source, destination):
``Ascend`` ``GPU`` ``CPU``
Examples:
>>> import mindspore.numpy as np
>>> x = np.zeros((3, 4, 5))
>>> output = np.moveaxis(x, 0, -1)
>>> print(output.shape)
@ -1244,6 +1245,7 @@ def tile(a, reps):
``Ascend`` ``GPU`` ``CPU``
Examples:
>>> import mindspore.numpy as np
>>> a = np.array([0, 1, 2])
>>> output = np.tile(a, 2)
>>> print(output)
@ -1298,6 +1300,7 @@ def broadcast_to(array, shape):
``Ascend`` ``GPU`` ``CPU``
Example:
>>> import mindspore.numpy as np
>>> x = np.array([1, 2, 3])
>>> output = np.broadcast_to(x, (3, 3))
>>> print(output)
@ -1333,6 +1336,7 @@ def broadcast_arrays(*args):
``Ascend`` ``GPU`` ``CPU``
Example:
>>> import mindspore.numpy as np
>>> x = np.array([[1,2,3]])
>>> y = np.array([[4],[5]])
>>> output = np.broadcast_arrays(x, y)
@ -1600,6 +1604,7 @@ def flip(m, axis=None):
``Ascend`` ``GPU`` ``CPU``
Example:
>>> import mindspore.numpy as np
>>> A = np.arange(8.0).reshape((2,2,2))
>>> output = np.flip(A)
>>> print(output)
@ -1653,6 +1658,7 @@ def flipud(m):
``Ascend`` ``GPU`` ``CPU``
Example:
>>> import mindspore.numpy as np
>>> A = np.arange(8.0).reshape((2,2,2))
>>> output = np.flipud(A)
>>> print(output)
@ -1685,6 +1691,7 @@ def fliplr(m):
``Ascend`` ``GPU`` ``CPU``
Example:
>>> import mindspore.numpy as np
>>> A = np.arange(8.0).reshape((2,2,2))
>>> output = np.fliplr(A)
>>> print(output)
@ -1723,6 +1730,7 @@ def take_along_axis(arr, indices, axis):
``Ascend`` ``GPU`` ``CPU``
Example:
>>> import mindspore.numpy as np
>>> x = np.arange(12).reshape(3, 4)
>>> indices = np.arange(3).reshape(1, 3)
>>> output = np.take_along_axis(x, indices, 1)
@ -1818,6 +1826,7 @@ def take(a, indices, axis=None, mode='raise'):
``Ascend`` ``GPU`` ``CPU``
Examples:
>>> import mindspore.numpy as np
>>> a = np.array([4, 3, 5, 7, 6, 8])
>>> indices = np.array([0, 1, 4])
>>> output = np.take(a, indices)
@ -1880,6 +1889,7 @@ def repeat(a, repeats, axis=None):
``Ascend`` ``GPU`` ``CPU``
Examples:
>>> import mindspore.numpy as np
>>> output = np.repeat(np.array(3), 4)
>>> print(output)
[3 3 3 3]

@ -107,6 +107,7 @@ def less_equal(x1, x2, out=None, where=True, dtype=None):
``Ascend`` ``GPU`` ``CPU``
Examples:
>>> import mindspore.numpy as np
>>> output = np.less_equal(np.array([4, 2, 1]), np.array([2, 2, 2]))
>>> print(output)
[False True True]
@ -154,6 +155,7 @@ def less(x1, x2, out=None, where=True, dtype=None):
``Ascend`` ``GPU`` ``CPU``
Examples:
>>> import mindspore.numpy as np
>>> output = np.less(np.array([1, 2]), np.array([2, 2]))
>>> print(output)
[ True False]
@ -200,6 +202,7 @@ def greater_equal(x1, x2, out=None, where=True, dtype=None):
``Ascend`` ``GPU`` ``CPU``
Examples:
>>> import mindspore.numpy as np
>>> output = np.greater_equal(np.array([4, 2, 1]), np.array([2, 2, 2]))
>>> print(output)
[ True True False]
@ -246,6 +249,7 @@ def greater(x1, x2, out=None, where=True, dtype=None):
``Ascend`` ``GPU`` ``CPU``
Examples:
>>> import mindspore.numpy as np
>>> output = np.greater(np.array([4, 2]), np.array([2, 2]))
>>> print(output)
[ True False]
@ -292,6 +296,7 @@ def equal(x1, x2, out=None, where=True, dtype=None):
``Ascend`` ``GPU`` ``CPU``
Examples:
>>> import mindspore.numpy as np
>>> output = np.equal(np.array([0, 1, 3]), np.arange(3))
>>> print(output)
[ True True False]
@ -338,6 +343,7 @@ def isfinite(x, out=None, where=True, dtype=None):
``Ascend`` ``GPU`` ``CPU``
Examples:
>>> import mindspore.numpy as np
>>> output = np.isfinite(np.array([np.inf, 1., np.nan]).astype('float32'))
>>> print(output)
[False True False]
@ -390,6 +396,7 @@ def isnan(x, out=None, where=True, dtype=None):
``GPU`` ``CPU``
Examples:
>>> import mindspore.numpy as np
>>> output = np.isnan(np.array(np.nan, np.float32))
>>> print(output)
True
@ -451,6 +458,7 @@ def isinf(x, out=None, where=True, dtype=None):
``GPU`` ``CPU``
Examples:
>>> import mindspore.numpy as np
>>> output = np.isinf(np.array(np.inf, np.float32))
>>> print(output)
True
@ -495,6 +503,7 @@ def isposinf(x):
``GPU`` ``CPU``
Examples:
>>> import mindspore.numpy as np
>>> output = np.isposinf(np.array([-np.inf, 0., np.inf], np.float32))
>>> print(output)
[False False True]
@ -525,6 +534,7 @@ def isneginf(x):
``GPU`` ``CPU``
Examples:
>>> import mindspore.numpy as np
>>> output = np.isneginf(np.array([-np.inf, 0., np.inf], np.float32))
>>> print(output)
[ True False False]
@ -561,6 +571,7 @@ def isscalar(element):
``Ascend`` ``GPU`` ``CPU``
Examples:
>>> import mindspore.numpy as np
>>> output = np.isscalar(3.1)
>>> print(output)
True

@ -261,6 +261,7 @@ def rad2deg(x, out=None, where=True, dtype=None):
``Ascend`` ``GPU`` ``CPU``
Examples:
>>> import mindspore.numpy as np
>>> x = np.asarray([1, 2, 3, -4, -5])
>>> output = np.rad2deg(x)
>>> print(output)
@ -310,6 +311,7 @@ def add(x1, x2, out=None, where=True, dtype=None):
``Ascend`` ``GPU`` ``CPU``
Examples:
>>> import mindspore.numpy as np
>>> x1 = np.full((3, 2), [1, 2])
>>> x2 = np.full((3, 2), [3, 4])
>>> output = np.add(x1, x2)
@ -363,6 +365,7 @@ def subtract(x1, x2, out=None, where=True, dtype=None):
``Ascend`` ``GPU`` ``CPU``
Examples:
>>> import mindspore.numpy as np
>>> x1 = np.full((3, 2), [1, 2])
>>> x2 = np.full((3, 2), [3, 4])
>>> output = np.subtract(x1, x2)
@ -411,6 +414,7 @@ def multiply(x1, x2, out=None, where=True, dtype=None):
``Ascend`` ``GPU`` ``CPU``
Examples:
>>> import mindspore.numpy as np
>>> x1 = np.full((3, 2), [1, 2])
>>> x2 = np.full((3, 2), [3, 4])
>>> output = np.multiply(x1, x2)
@ -468,6 +472,7 @@ def divide(x1, x2, out=None, where=True, dtype=None):
``Ascend`` ``GPU`` ``CPU``
Examples:
>>> import mindspore.numpy as np
>>> x1 = np.full((3, 2), [1, 2])
>>> x2 = np.full((3, 2), [3, 4])
>>> output = np.divide(x1, x2)
@ -520,6 +525,7 @@ def true_divide(x1, x2, out=None, where=True, dtype=None):
``Ascend`` ``GPU`` ``CPU``
Examples:
>>> import mindspore.numpy as np
>>> x1 = np.full((3, 2), [1, 2])
>>> x2 = np.full((3, 2), [3, 4])
>>> output = np.true_divide(x1, x2)
@ -571,6 +577,7 @@ def power(x1, x2, out=None, where=True, dtype=None):
``Ascend`` ``GPU`` ``CPU``
Examples:
>>> import mindspore.numpy as np
>>> x1 = np.full((3, 2), [1, 2]).astype('float32')
>>> x2 = np.full((3, 2), [3, 4]).astype('float32')
>>> output = np.power(x1, x2)
@ -627,6 +634,7 @@ def float_power(x1, x2, out=None, where=True, dtype=None):
``Ascend`` ``GPU`` ``CPU``
Examples:
>>> import mindspore.numpy as np
>>> x1 = np.arange(6)
>>> x2 = np.array(3)
>>> output = np.float_power(x1, x2)
@ -1007,6 +1015,7 @@ def tensordot(a, b, axes=2):
``Ascend`` ``GPU`` ``CPU``
Examples:
>>> import mindspore.numpy as np
>>> a = np.ones((3, 4, 5))
>>> b = np.ones((4, 3, 2))
>>> output = np.tensordot(a, b, axes=([1,0],[0,1]))
@ -1284,6 +1293,7 @@ def matmul(x1, x2, dtype=None):
``Ascend`` ``GPU`` ``CPU``
Examples:
>>> import mindspore.numpy as np
>>> x1 = np.arange(2*3*4).reshape(2, 3, 4).astype('float32')
>>> x2 = np.arange(4*5).reshape(4, 5).astype('float32')
>>> output = np.matmul(x1, x2)
@ -1335,6 +1345,7 @@ def square(x, out=None, where=True, dtype=None):
``Ascend`` ``GPU`` ``CPU``
Examples:
>>> import mindspore.numpy as np
>>> x = np.square(np.arange(6).reshape(2, 3).astype('float32'))
>>> print(x)
[[ 0. 1. 4.]
@ -1381,6 +1392,7 @@ def sqrt(x, out=None, where=True, dtype=None):
``Ascend`` ``GPU`` ``CPU``
Examples:
>>> import mindspore.numpy as np
>>> x = np.arange(6).reshape(2, 3).astype('float32')
>>> x_squared = np.square(x)
>>> output = np.sqrt(x_squared)
@ -1430,6 +1442,7 @@ def reciprocal(x, out=None, where=True, dtype=None):
``Ascend`` ``GPU`` ``CPU``
Examples:
>>> import mindspore.numpy as np
>>> x = np.arange(1, 7).reshape(2, 3).astype('float32')
>>> output = np.reciprocal(x)
>>> print(output)
@ -1482,6 +1495,7 @@ def log(x, out=None, where=True, dtype=None):
``Ascend`` ``GPU`` ``CPU``
Examples:
>>> import mindspore.numpy as np
>>> x = np.array([2, 3, 4]).astype('float32')
>>> output = np.log(x)
>>> print(output)
@ -1534,6 +1548,7 @@ def maximum(x1, x2, out=None, where=True, dtype=None):
``Ascend`` ``GPU`` ``CPU``
Examples:
>>> import mindspore.numpy as np
>>> output = np.maximum(np.array([2, 3, 4]), np.array([1, 5, 2]))
>>> print(output)
[2 5 4]
@ -1598,6 +1613,7 @@ def heaviside(x1, x2, out=None, where=True, dtype=None):
``Ascend`` ``GPU`` ``CPU``
Examples:
>>> import mindspore.numpy as np
>>> output = np.heaviside(np.array([-1.5, 0, 2.0]), np.array(0.5))
>>> print(output)
[0. 0.5 1. ]
@ -1666,6 +1682,7 @@ def amax(a, axis=None, keepdims=False, initial=None, where=True):
``Ascend`` ``GPU`` ``CPU``
Examples:
>>> import mindspore.numpy as np
>>> a = np.arange(4).reshape((2,2)).astype('float32')
>>> output = np.amax(a)
>>> print(output)
@ -1721,6 +1738,7 @@ def amin(a, axis=None, keepdims=False, initial=None, where=True):
``Ascend`` ``GPU`` ``CPU``
Examples:
>>> import mindspore.numpy as np
>>> a = np.arange(4).reshape((2,2)).astype('float32')
>>> output = np.amin(a)
>>> print(output)
@ -1784,6 +1802,7 @@ def hypot(x1, x2, out=None, where=True, dtype=None):
``Ascend`` ``GPU`` ``CPU``
Examples:
>>> import mindspore.numpy as np
>>> output = np.hypot(3*np.ones((3, 3)), 4*np.ones((3, 3)))
>>> print(output)
[[5. 5. 5.]
@ -1847,6 +1866,7 @@ def floor(x, out=None, where=True, dtype=None):
``Ascend`` ``GPU`` ``CPU``
Examples:
>>> import mindspore.numpy as np
>>> output = np.floor(np.array([-1.7, -1.5, -0.2, 0.2, 1.5, 1.7, 2.0]))
>>> print(output)
[-2. -2. -1. 0. 1. 1. 2.]
@ -1892,6 +1912,7 @@ def floor_divide(x1, x2, out=None, where=True, dtype=None):
``Ascend`` ``GPU`` ``CPU``
Examples:
>>> import mindspore.numpy as np
>>> output = np.floor_divide(np.array([1., 2., 3., 4.]), np.array(2.5))
>>> print(output)
[0. 0. 1. 1.]
@ -1964,6 +1985,7 @@ def remainder(x1, x2, out=None, where=True, dtype=None):
``Ascend`` ``GPU`` ``CPU``
Examples:
>>> import mindspore.numpy as np
>>> output = np.remainder(np.array([4, 7]), np.array([2, 3]))
>>> print(output)
[0 1]
@ -1997,6 +2019,7 @@ def fix(x):
``Ascend`` ``GPU`` ``CPU``
Examples:
>>> import mindspore.numpy as np
>>> output = np.fix(np.array([2.1, 2.9, -2.1, -2.9]))
>>> print(output)
[ 2. 2. -2. -2.]
@ -2052,6 +2075,7 @@ def fmod(x1, x2, out=None, where=True, dtype=None):
``Ascend`` ``GPU`` ``CPU``
Examples:
>>> import mindspore.numpy as np
>>> output = np.fmod(np.array([-3, -2, -1, 1, 2, 3]), np.array(2))
>>> print(output)
[-1 0 -1 1 0 1]
@ -2099,6 +2123,7 @@ def trunc(x, out=None, where=True, dtype=None):
``Ascend`` ``GPU`` ``CPU``
Examples:
>>> import mindspore.numpy as np
>>> output = np.trunc(np.array([-1.7, -1.5, -0.2, 0.2, 1.5, 1.7, 2.0]))
>>> print(output)
[-1. -1. -0. 0. 1. 1. 2.]
@ -2144,6 +2169,7 @@ def exp(x, out=None, where=True, dtype=None):
``Ascend`` ``GPU`` ``CPU``
Examples:
>>> import mindspore.numpy as np
>>> output = np.exp(np.arange(5).astype(np.float32))
>>> print(output)
[ 1. 2.718282 7.3890557 20.085537 54.598145 ]
@ -2189,9 +2215,10 @@ def expm1(x, out=None, where=True, dtype=None):
``Ascend`` ``GPU`` ``CPU``
Examples:
>>> import mindspore.numpy as np
>>> output = np.expm1(np.arange(5).astype(np.float32))
>>> print(output)
[ 0. 1.7182819 6.389056 19.085537 53.59815 ]
[ 0. 1.7182819 6.389056 19.085537 53.59815 ]
"""
return _apply_tensor_op(F.tensor_expm1, x, out=out, where=where, dtype=dtype)
@ -2377,6 +2404,7 @@ def cumsum(a, axis=None, dtype=None):
``Ascend`` ``GPU`` ``CPU``
Examples:
>>> import mindspore.numpy as np
>>> output = np.cumsum(np.ones((3,3)), axis=0)
>>> print(output)
[[1. 1. 1.]

Loading…
Cancel
Save