Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
modify docs
Browse files Browse the repository at this point in the history
  • Loading branch information
JiangZhaoh committed Feb 25, 2020
1 parent 0bc06ea commit 995d347
Show file tree
Hide file tree
Showing 12 changed files with 181 additions and 138 deletions.
71 changes: 47 additions & 24 deletions python/mxnet/ndarray/numpy/_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ def zeros(shape, dtype=float, order='C', ctx=None): # pylint: disable=redefined
shape : int or tuple of int
The shape of the empty array.
dtype : str or numpy.dtype, optional
An optional value type (default is `float32` or 'float64', which depends on your current default dtype).
An optional value type.
- When npx.is_np_default_dtype() returns Flase, default dtype is float32;
- When npx.is_np_default_dtype() returns True, default dtype is float64.
Note that this behavior is different from NumPy's `zeros` function where `float64`
is the default value, here we can set 'float32' or 'float64' as your default dtype,
because `float32` is considered as the default data type in deep learning.
Expand Down Expand Up @@ -129,7 +131,9 @@ def ones(shape, dtype=None, order='C', ctx=None): # pylint: disable=redefined-o
shape : int or tuple of int
The shape of the empty array.
dtype : str or numpy.dtype, optional
An optional value type. Default is depend on your current default dtype.
An optional value type.
- When npx.is_np_default_dtype() returns Flase, default dtype is float32;
- When npx.is_np_default_dtype() returns True, default dtype is float64.
Note that this behavior is different from NumPy's `ones` function where
`float64` is the default value.
order : {'C'}, optional, default: 'C'
Expand Down Expand Up @@ -315,6 +319,8 @@ def full(shape, fill_value, dtype=None, order='C', ctx=None, out=None): # pylin
dtype : data-type, optional
The desired data-type for the array. The default, `None`, means
`np.array(fill_value).dtype`.
- When npx.is_np_default_dtype() returns Flase, default dtype is float32;
- When npx.is_np_default_dtype() returns True, default dtype is float64.
order : {'C'}, optional
Whether to store multidimensional data in C- or Fortran-contiguous
(row- or column-wise) order in memory. Currently only supports C order.
Expand Down Expand Up @@ -524,8 +530,9 @@ def arange(start, stop=None, step=1, dtype=None, ctx=None):
step size is 1. If `step` is specified as a position argument,
`start` must also be given.
dtype : dtype
The type of the output array. The default is `float32` or 'float64',
which depends on your current default dtype.
The type of the output array.
- When npx.is_np_default_dtype() returns Flase, default dtype is float32;
- When npx.is_np_default_dtype() returns True, default dtype is float64.
Returns
-------
Expand Down Expand Up @@ -565,7 +572,8 @@ def identity(n, dtype=None, ctx=None):
Number of rows (and columns) in `n` x `n` output.
dtype : data-type, optional
Data-type of the output.
Default dtype is 'float32' or 'float64', which depends on your current default dtype.
- When npx.is_np_default_dtype() returns Flase, default dtype is float32;
- When npx.is_np_default_dtype() returns True, default dtype is float64.
ctx : Context, optional
An optional device context (default is the current default context).
Expand Down Expand Up @@ -1077,8 +1085,9 @@ def divide(x1, x2, out=None, **kwargs):
according to the following rules:
* If both inputs are of floating number types, the output is the more precise type.
* If only one of the inputs is floating number type, the result is that type.
* If both inputs are of integer types (including boolean), the output is of float32 or
float64 type, which depends on your current default dtype.
* If both inputs are of integer types (including boolean), the output is of default dtype.
- When npx.is_np_default_dtype() returns Flase, default dtype is float32;
- When npx.is_np_default_dtype() returns True, default dtype is float64.
"""
return _ufunc_helper(x1, x2, _npi.true_divide, _np.divide, _npi.true_divide_scalar,
_npi.rtrue_divide_scalar, out)
Expand Down Expand Up @@ -1116,8 +1125,9 @@ def true_divide(x1, x2, out=None):
according to the following rules:
* If both inputs are of floating number types, the output is the more precise type.
* If only one of the inputs is floating number type, the result is that type.
* If both inputs are of integer types (including boolean), the output is of float32 or
float64 type, which depends on your current default dtype.
* If both inputs are of integer types (including boolean), the output is of default dtype.
- When npx.is_np_default_dtype() returns Flase, default dtype is float32;
- When npx.is_np_default_dtype() returns True, default dtype is float64.
"""
return _ufunc_helper(x1, x2, _npi.true_divide, _np.divide, _npi.true_divide_scalar,
_npi.rtrue_divide_scalar, out)
Expand Down Expand Up @@ -1621,6 +1631,8 @@ def eye(N, M=None, k=0, dtype=float, **kwargs):
and a negative value to a lower diagonal.
dtype : data-type, optional
Data-type of the returned array.
- When npx.is_np_default_dtype() returns Flase, default dtype is float32;
- When npx.is_np_default_dtype() returns True, default dtype is float64.
Returns
-------
Expand Down Expand Up @@ -4505,8 +4517,9 @@ def average(a, axis=None, weights=None, returned=False, out=None):
Return the average along the specified axis.
When returned is True, return a tuple with the average as the first element
and the sum of the weights as the second element. sum_of_weights is of the same type as retval.
If a is integral, the result dtype will be float32 or float64, which depends on your current
default dtype, otherwise it will be the same as dtype of a.
If a is integral, the result dtype will be current default dtype, otherwise it will be the same
as dtype of a. (i.e. When npx.is_np_default_dtype() returns Flase, default dtype is float32; When
npx.is_np_default_dtype() returns True, default dtype is float64.)
Raises
--------
Expand All @@ -4529,7 +4542,9 @@ def average(a, axis=None, weights=None, returned=False, out=None):
- Does not guarantee the same behavior with numpy when given float16 dtype and overflow happens
- Does not support complex dtype
- The dtypes of a and weights must be the same
- Integral a results in float32 or float64 returned dtype, which depends on your current default dtype
- Integral a results in default dtype.
i.e. When npx.is_np_default_dtype() returns Flase, default dtype is float32;
When npx.is_np_default_dtype() returns True, default dtype is float64.
Examples
--------
Expand Down Expand Up @@ -4573,8 +4588,9 @@ def mean(a, axis=None, dtype=None, out=None, keepdims=False): # pylint: disable
instead of a single axis or all the axes as before.
dtype : data-type, optional
Type to use in computing the mean.
For integer inputs, the default is float32 or float64, which depends on your current default dtype ;
for floating point inputs, it is the same as the input dtype.
For integer inputs, the default is your current default dtype (i.e. When npx.is_np_default_dtype() returns
Flase, default dtype is float32; When npx.is_np_default_dtype() returns True, default dtype is float64.);
For floating point inputs, it is the same as the input dtype.
out : ndarray, optional
Alternate output array in which to place the result. The default is None; if provided,
it must have the same shape and type as the expected output
Expand All @@ -4596,7 +4612,9 @@ def mean(a, axis=None, dtype=None, out=None, keepdims=False): # pylint: disable
<https://docs.scipy.org/doc/numpy/reference/generated/numpy.mean.html>`_ in
the following way(s):
- only ndarray is accepted as valid input, python iterables or scalar is not supported
- default data type for integer input is float32 or float64, which depends on your current default dtype
- default data type for integer input is float32 or float64, which depends on your current default dtype.
When npx.is_np_default_dtype() returns Flase, default dtype is float32;
When npx.is_np_default_dtype() returns True, default dtype is float64.
Examples
--------
>>> a = np.array([[1, 2], [3, 4]])
Expand Down Expand Up @@ -4700,9 +4718,11 @@ def var(a, axis=None, dtype=None, out=None, ddof=0, keepdims=False): # pylint:
If this is a tuple of ints, a variance is performed over multiple axes,
instead of a single axis or all the axes as before.
dtype : data-type, optional
Type to use in computing the variance. For arrays of integer type
the default is `float32` or 'float64', which depends on your current
default dtype; for arrays of float types it is the same as the array type.
Type to use in computing the variance.
For arrays of integer type the default is `float32` or 'float64',
When npx.is_np_default_dtype() returns Flase, default dtype is float32,
When npx.is_np_default_dtype() returns True, default dtype is float64;
For arrays of float types it is the same as the array type.
out : ndarray, optional
Alternate output array in which to place the result. It must have
the same shape as the expected output, but the type is cast if
Expand Down Expand Up @@ -4763,7 +4783,7 @@ def indices(dimensions, dtype=None, ctx=None):
dimensions : sequence of ints
The shape of the grid.
dtype : data-type, optional
The desired data-type for the array. Default is `int32`.
The desired data-type for the array. Default is `int64`.
ctx : device context, optional
Device context on which the memory is allocated. Default is
`mxnet.context.current_context()`.
Expand Down Expand Up @@ -4793,10 +4813,10 @@ def indices(dimensions, dtype=None, ctx=None):
(2, 2, 3)
>>> grid[0] # row indices
array([[0, 0, 0],
[1, 1, 1]], dtype=int32)
[1, 1, 1]], dtype=int64)
>>> grid[1] # column indices
array([[0, 0, 0],
[1, 1, 1]], dtype=int32)
[1, 1, 1]], dtype=int64)
The indices can be used as an index into an array.
Expand Down Expand Up @@ -5018,7 +5038,8 @@ def hanning(M, ctx=None):
out : ndarray, shape(M,)
The window, with the maximum value normalized to one (the value
one appears only if `M` is odd).
Default is 'float32' or 'float64', which depends on your current default dtype.
When npx.is_np_default_dtype() returns Flase, default dtype is float32;
When npx.is_np_default_dtype() returns True, default dtype is float64.
Note that you need select numpy.float32 or float64 in this operator.
See Also
Expand Down Expand Up @@ -5099,7 +5120,8 @@ def hamming(M, ctx=None):
out : ndarray, shape(M,)
The window, with the maximum value normalized to one (the value
one appears only if `M` is odd).
Default is 'float32' or 'float64', which depends on your current default dtype.
When npx.is_np_default_dtype() returns Flase, default dtype is float32;
When npx.is_np_default_dtype() returns True, default dtype is float64.
Note that you need select numpy.float32 or float64 in this operator.
See Also
Expand Down Expand Up @@ -5181,7 +5203,8 @@ def blackman(M, ctx=None):
out : ndarray
The window, with the maximum value normalized to one (the value one
appears only if the number of samples is odd).
Default is 'float32' or 'float64', which depends on your current default dtype.
When npx.is_np_default_dtype() returns Flase, default dtype is float32;
When npx.is_np_default_dtype() returns True, default dtype is float64.
Note that you need select numpy.float32 or float64 in this operator.
See Also
Expand Down
20 changes: 15 additions & 5 deletions python/mxnet/ndarray/numpy/random.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,9 @@ def uniform(low=0.0, high=1.0, size=None, dtype=None, ctx=None, out=None):
a scalar tensor containing a single value is returned if
``low`` and ``high`` are both scalars.
dtype : {'float16', 'float32', 'float64'}, optional
Data type of output samples. Default is 'float32'
Data type of output samples.
When npx.is_np_default_dtype() returns Flase, default dtype is float32;
When npx.is_np_default_dtype() returns True, default dtype is float64.
ctx : Context, optional
Device context of output. Default is current context.
out : ``ndarray``, optional
Expand Down Expand Up @@ -160,7 +162,9 @@ def normal(loc=0.0, scale=1.0, size=None, dtype=None, ctx=None, out=None):
samples are drawn. If size is `None` (default), a scalar tensor containing
a single value is returned if loc and scale are both scalars.
dtype : {'float16', 'float32', 'float64'}, optional
Data type of output samples. Default is 'float32'
Data type of output samples.
When npx.is_np_default_dtype() returns Flase, default dtype is float32;
When npx.is_np_default_dtype() returns True, default dtype is float64.
ctx : Context, optional
Device context of output. Default is current context.
out : ``ndarray``, optional
Expand Down Expand Up @@ -768,7 +772,9 @@ def gamma(shape, scale=1.0, size=None, dtype=None, ctx=None, out=None):
a single value is returned if ``shape`` and ``scale`` are both scalars.
Otherwise, ``np.broadcast(shape, scale).size`` samples are drawn.
dtype : {'float16', 'float32', 'float64'}, optional
Data type of output samples. Default is 'float32'.
Data type of output samples.
When npx.is_np_default_dtype() returns Flase, default dtype is float32;
When npx.is_np_default_dtype() returns True, default dtype is float64.
ctx : Context, optional
Device context of output. Default is current context.
Expand Down Expand Up @@ -834,7 +840,9 @@ def beta(a, b, size=None, dtype=None, ctx=None):
a single value is returned if ``a`` and ``b`` are both scalars.
Otherwise, ``np.broadcast(a, b).size`` samples are drawn.
dtype : {'float16', 'float32', 'float64'}, optional
Data type of output samples. Default is 'float32'.
Data type of output samples.
When npx.is_np_default_dtype() returns Flase, default dtype is float32;
When npx.is_np_default_dtype() returns True, default dtype is float64.
ctx : Context, optional
Device context of output. Default is current context.
Expand Down Expand Up @@ -881,7 +889,9 @@ def chisquare(df, size=None, dtype=None, ctx=None):
a single value is returned if ``df`` is a scalar. Otherwise,
``np.array(df).size`` samples are drawn.
dtype : {'float16', 'float32', 'float64'}, optional
Data type of output samples. Default is 'float32'.
Data type of output samples.
When npx.is_np_default_dtype() returns Flase, default dtype is float32;
When npx.is_np_default_dtype() returns True, default dtype is float64.
Dtype 'float32' or 'float64' is strongly recommended,
since lower precision might lead to out of range issue.
ctx : Context, optional
Expand Down
Loading

0 comments on commit 995d347

Please sign in to comment.