diff --git a/python/mxnet/image.py b/python/mxnet/image.py index e61e0b8468ee..890de7d0ffb8 100644 --- a/python/mxnet/image.py +++ b/python/mxnet/image.py @@ -170,7 +170,7 @@ def fixed_crop(src, x0, y0, w, h, size=None, interp=2): def random_crop(src, size, interp=2): """Randomly crop `src` with `size` (width, height). - Upsample result if `src` is smaller than `size`. + Upsample result if `src` is smaller than `size`. Parameters ---------- @@ -239,7 +239,7 @@ def center_crop(src, size, interp=2): 4: Lanczos interpolation over 8x8 pixel neighborhood. - When shrinking an image, it will generally look best with AREA-based + When shrinking an image, it will generally look best with AREA-based interpolation, whereas, when enlarging an image, it will generally look best with Bicubic (slow) or Bilinear (faster but still looks OK). @@ -708,7 +708,6 @@ def read_image(self, fname): Example usage: ---------- >>> dataIter.read_image('Face.jpg') # returns decoded raw bytes. - '\xff\xd8\xff\xe0\x00...' """ with open(os.path.join(self.path_root, fname), 'rb') as fin: img = fin.read() diff --git a/python/mxnet/io.py b/python/mxnet/io.py index 28e220d16ed5..e9db93160f84 100644 --- a/python/mxnet/io.py +++ b/python/mxnet/io.py @@ -25,7 +25,7 @@ class DataDesc(namedtuple('DataDesc', ['name', 'shape'])): that the first axis is number of examples in the batch(N), C is number of channels, H is the height and W is the width of the image. - for sequential data, by default `layout` is set to ``NTC`` where + For sequential data, by default `layout` is set to ``NTC``, where N is number of examples in the batch, T the temporal axis representing time and C is the number of channels. diff --git a/python/mxnet/symbol.py b/python/mxnet/symbol.py index 4632f7d71b17..d09de16facd3 100644 --- a/python/mxnet/symbol.py +++ b/python/mxnet/symbol.py @@ -45,7 +45,7 @@ class Symbol(SymbolBase): __slots__ = [] def __repr__(self): - """Get a string representation of the symbol.""" + """Gets a string representation of the symbol.""" name = self.name if name is None: name = ', '.join([i.name for i in self]) @@ -453,7 +453,7 @@ def __getitem__(self, index): @property def name(self): - """Get name string from the symbol, this function only works for non-grouped symbol. + """Gets name string from the symbol, this function only works for non-grouped symbol. Returns ------- @@ -1412,7 +1412,7 @@ def bind(self, ctx, args, args_grad=None, grad_req='write', return executor def grad(self, wrt): - """Get the autodiff of current symbol. + """Gets the autodiff of current symbol. This function can only be used if current symbol is a loss function. @@ -1793,9 +1793,9 @@ def minimum(left, right): # pylint: disable=no-member # pylint: disable=redefined-builtin def hypot(left, right): - """Given the "legs" of a right triangle, return its hypotenuse. + """Given the "legs" of a right triangle, returns its hypotenuse. - Equivalent to "sqrt(left**2 + right**2)", element-wise. + Equivalent to :math:`\\sqrt(left^2 + right^2)`, element-wise. Both inputs can be Symbol or scalar number. Broadcasting is not supported. Parameters @@ -1836,7 +1836,7 @@ def hypot(left, right): def zeros(shape, dtype=None, **kwargs): - """Return a new symbol of given shape and type, filled with zeros. + """Returns a new symbol of given shape and type, filled with zeros. Parameters ---------- @@ -1856,7 +1856,7 @@ def zeros(shape, dtype=None, **kwargs): def ones(shape, dtype=None, **kwargs): - """Return a new symbol of given shape and type, filled with ones. + """Returns a new symbol of given shape and type, filled with ones. Parameters ---------- @@ -1876,7 +1876,7 @@ def ones(shape, dtype=None, **kwargs): def arange(start, stop=None, step=1.0, repeat=1, name=None, dtype=None): - """Return evenly spaced values within a given interval. + """Returns evenly spaced values within a given interval. Parameters ---------- diff --git a/src/operator/concat.cc b/src/operator/concat.cc index 85a8c7e7b2ee..49fa03e7e681 100644 --- a/src/operator/concat.cc +++ b/src/operator/concat.cc @@ -51,7 +51,7 @@ MXNET_REGISTER_OP_PROPERTY(Concat, ConcatProp) .. note:: `Concat` is deprecated. Use `concat` instead. The dimensions of the input arrays should be the same except the axis along - which they will concatenated. +which they will be concatenated. The dimension of the output array along the concatenated axis will be equal to the sum of the corresponding dimensions of the input arrays. diff --git a/src/operator/loss_binary_op.cc b/src/operator/loss_binary_op.cc index 31f23fd1a234..43bf6943e0c5 100644 --- a/src/operator/loss_binary_op.cc +++ b/src/operator/loss_binary_op.cc @@ -25,7 +25,7 @@ NNVM_REGISTER_OP(softmax_cross_entropy) .. math:: \text{CE(label, output)} = - \sum_i \text{label}_i \log(\text{output}_i) - Example:: +Example:: x = [[1, 2, 3], [11, 7, 5]] diff --git a/src/operator/slice_channel.cc b/src/operator/slice_channel.cc index 2467afdda5b9..689f0109214f 100644 --- a/src/operator/slice_channel.cc +++ b/src/operator/slice_channel.cc @@ -72,6 +72,8 @@ Example:: along the `axis` which it is split. Also `squeeze_axis` can be set to true only if ``input.shape[axis] == num_outputs``. +Example:: + z = split(x, axis=0, num_outputs=3, squeeze_axis=1) // a list of 3 arrays with shape (2, 1) z = [[ 1.] [ 2.]] diff --git a/src/operator/softmax_output.cc b/src/operator/softmax_output.cc index 05946ff9f094..06225a3b0be7 100644 --- a/src/operator/softmax_output.cc +++ b/src/operator/softmax_output.cc @@ -72,7 +72,7 @@ MXNET_REGISTER_OP_PROPERTY(SoftmaxOutput, SoftmaxOutputProp) - If the parameter `use_ignore` is ``true``, `ignore_label` can specify input instances with a particular label to be ignored during backward propagation. **This has no effect when - softmax** `output` **has same shape as** `label`. + softmax `output` has same shape as `label`**. Example:: diff --git a/src/operator/tensor/indexing_op.cc b/src/operator/tensor/indexing_op.cc index f9023054a10f..5f010fdfc62c 100644 --- a/src/operator/tensor/indexing_op.cc +++ b/src/operator/tensor/indexing_op.cc @@ -189,7 +189,7 @@ The locations represented by `indices` take value `on_value`, while all other locations take value `off_value`. `one_hot` operation with `indices` of shape ``(i0, i1)`` and `depth` of ``d`` would result - in an output array of shape ``(i0, i1, d)`` with:: +in an output array of shape ``(i0, i1, d)`` with:: output[i,j,:] = off_value output[i,j,indices[i,j]] = on_value diff --git a/src/operator/tensor/matrix_op.cc b/src/operator/tensor/matrix_op.cc index 1a9eaf505cb8..f3d69733a814 100644 --- a/src/operator/tensor/matrix_op.cc +++ b/src/operator/tensor/matrix_op.cc @@ -230,7 +230,7 @@ and ``end=(e_1, e_2, ... e_n)`` indices will result in an array with the shape ``(e_1-b_0, ..., e_n-b_n-1)``. The resulting array's *k*-th dimension contains elements - from the *k*-th dimension of the input array with the open range ``[b_k, e_k)``. +from the *k*-th dimension of the input array with the open range ``[b_k, e_k)``. Example:: diff --git a/src/operator/tensor/multisample_op.cc b/src/operator/tensor/multisample_op.cc index 52db07f09081..b5179b31426e 100644 --- a/src/operator/tensor/multisample_op.cc +++ b/src/operator/tensor/multisample_op.cc @@ -155,13 +155,15 @@ DMLC_REGISTER_PARAMETER(MultiSampleParam); inline std::string uniform_desc() { return std::string(R"code(Concurrent sampling from multiple uniform distributions on the intervals given by *[low,high)*. + The parameters of the distributions are provided as input arrays. Let *[s]* be the shape of the input arrays, *n* be the dimension of *[s]*, *[t]* be the shape specified as the parameter of the operator, and *m* be the dimension -of *[t]*. Then the output will be a *(n+m)*-dimensional array with shape *[s]x[t]*. For any -valid *n*-dimensional index *i* with respect to the input arrays, *output[i]* will be -an *m*-dimensional array that holds randomly drawn samples from the distribution which -is parameterized by the input values at index *i*. If the shape parameter of the +of *[t]*. Then the output will be a *(n+m)*-dimensional array with shape *[s]x[t]*. + +For any valid *n*-dimensional index *i* with respect to the input arrays, *output[i]* +will be an *m*-dimensional array that holds randomly drawn samples from the distribution +which is parameterized by the input values at index *i*. If the shape parameter of the operator is not set, then one sample will be drawn per distribution and the output array has the same shape as the input arrays. @@ -182,13 +184,15 @@ Examples:: inline std::string normal_desc() { return std::string(R"code(Concurrent sampling from multiple normal distributions with parameters *mu* (mean) and *sigma* (standard deviation). + The parameters of the distributions are provided as input arrays. Let *[s]* be the shape of the input arrays, *n* be the dimension of *[s]*, *[t]* be the shape specified as the parameter of the operator, and *m* be the dimension -of *[t]*. Then the output will be a *(n+m)*-dimensional array with shape *[s]x[t]*. For any -valid *n*-dimensional index *i* with respect to the input arrays, *output[i]* will be -an *m*-dimensional array that holds randomly drawn samples from the distribution which -is parameterized by the input values at index *i*. If the shape parameter of the +of *[t]*. Then the output will be a *(n+m)*-dimensional array with shape *[s]x[t]*. + +For any valid *n*-dimensional index *i* with respect to the input arrays, *output[i]* +will be an *m*-dimensional array that holds randomly drawn samples from the distribution +which is parameterized by the input values at index *i*. If the shape parameter of the operator is not set, then one sample will be drawn per distribution and the output array has the same shape as the input arrays. @@ -209,13 +213,15 @@ Examples:: inline std::string gamma_desc() { return std::string(R"code(Concurrent sampling from multiple gamma distributions with parameters *alpha* (shape) and *beta* (scale). + The parameters of the distributions are provided as input arrays. Let *[s]* be the shape of the input arrays, *n* be the dimension of *[s]*, *[t]* be the shape specified as the parameter of the operator, and *m* be the dimension -of *[t]*. Then the output will be a *(n+m)*-dimensional array with shape *[s]x[t]*. For any -valid *n*-dimensional index *i* with respect to the input arrays, *output[i]* will be -an *m*-dimensional array that holds randomly drawn samples from the distribution which -is parameterized by the input values at index *i*. If the shape parameter of the +of *[t]*. Then the output will be a *(n+m)*-dimensional array with shape *[s]x[t]*. + +For any valid *n*-dimensional index *i* with respect to the input arrays, *output[i]* +will be an *m*-dimensional array that holds randomly drawn samples from the distribution +which is parameterized by the input values at index *i*. If the shape parameter of the operator is not set, then one sample will be drawn per distribution and the output array has the same shape as the input arrays. @@ -236,13 +242,15 @@ Examples:: inline std::string exponential_desc() { return std::string(R"code(Concurrent sampling from multiple exponential distributions with parameters lambda (rate). + The parameters of the distributions are provided as an input array. Let *[s]* be the shape of the input array, *n* be the dimension of *[s]*, *[t]* be the shape specified as the parameter of the operator, and *m* be the dimension -of *[t]*. Then the output will be a *(n+m)*-dimensional array with shape *[s]x[t]*. For any -valid *n*-dimensional index *i* with respect to the input array, *output[i]* will be -an *m*-dimensional array that holds randomly drawn samples from the distribution which -is parameterized by the input value at index *i*. If the shape parameter of the +of *[t]*. Then the output will be a *(n+m)*-dimensional array with shape *[s]x[t]*. + +For any valid *n*-dimensional index *i* with respect to the input array, *output[i]* +will be an *m*-dimensional array that holds randomly drawn samples from the distribution +which is parameterized by the input value at index *i*. If the shape parameter of the operator is not set, then one sample will be drawn per distribution and the output array has the same shape as the input array. @@ -262,15 +270,18 @@ Examples:: inline std::string poisson_desc() { return std::string(R"code(Concurrent sampling from multiple Poisson distributions with parameters lambda (rate). + The parameters of the distributions are provided as an input array. Let *[s]* be the shape of the input array, *n* be the dimension of *[s]*, *[t]* be the shape specified as the parameter of the operator, and *m* be the dimension -of *[t]*. Then the output will be a *(n+m)*-dimensional array with shape *[s]x[t]*. For any -valid *n*-dimensional index *i* with respect to the input array, *output[i]* will be -an *m*-dimensional array that holds randomly drawn samples from the distribution which -is parameterized by the input value at index *i*. If the shape parameter of the +of *[t]*. Then the output will be a *(n+m)*-dimensional array with shape *[s]x[t]*. + +For any valid *n*-dimensional index *i* with respect to the input array, *output[i]* +will be an *m*-dimensional array that holds randomly drawn samples from the distribution +which is parameterized by the input value at index *i*. If the shape parameter of the operator is not set, then one sample will be drawn per distribution and the output array has the same shape as the input array. + Samples will always be returned as a floating point data type. Examples:: @@ -289,15 +300,18 @@ Examples:: inline std::string negative_binomial_desc() { return std::string(R"code(Concurrent sampling from multiple negative binomial distributions with parameters *k* (failure limit) and *p* (failure probability). + The parameters of the distributions are provided as input arrays. Let *[s]* be the shape of the input arrays, *n* be the dimension of *[s]*, *[t]* be the shape specified as the parameter of the operator, and *m* be the dimension -of *[t]*. Then the output will be a *(n+m)*-dimensional array with shape *[s]x[t]*. For any -valid *n*-dimensional index *i* with respect to the input arrays, *output[i]* will be -an *m*-dimensional array that holds randomly drawn samples from the distribution which -is parameterized by the input values at index *i*. If the shape parameter of the +of *[t]*. Then the output will be a *(n+m)*-dimensional array with shape *[s]x[t]*. + +For any valid *n*-dimensional index *i* with respect to the input arrays, *output[i]* +will be an *m*-dimensional array that holds randomly drawn samples from the distribution +which is parameterized by the input values at index *i*. If the shape parameter of the operator is not set, then one sample will be drawn per distribution and the output array has the same shape as the input arrays. + Samples will always be returned as a floating point data type. Examples:: @@ -317,15 +331,18 @@ Examples:: inline std::string generalized_negative_binomial_desc() { return std::string(R"code(Concurrent sampling from multiple generalized negative binomial distributions with parameters *mu* (mean) and *alpha* (dispersion). + The parameters of the distributions are provided as input arrays. Let *[s]* be the shape of the input arrays, *n* be the dimension of *[s]*, *[t]* be the shape specified as the parameter of the operator, and *m* be the dimension -of *[t]*. Then the output will be a *(n+m)*-dimensional array with shape *[s]x[t]*. For any -valid *n*-dimensional index *i* with respect to the input arrays, *output[i]* will be -an *m*-dimensional array that holds randomly drawn samples from the distribution which -is parameterized by the input values at index *i*. If the shape parameter of the +of *[t]*. Then the output will be a *(n+m)*-dimensional array with shape *[s]x[t]*. + +For any valid *n*-dimensional index *i* with respect to the input arrays, *output[i]* +will be an *m*-dimensional array that holds randomly drawn samples from the distribution +which is parameterized by the input values at index *i*. If the shape parameter of the operator is not set, then one sample will be drawn per distribution and the output array has the same shape as the input arrays. + Samples will always be returned as a floating point data type. Examples:: diff --git a/src/operator/upsampling.cc b/src/operator/upsampling.cc index 15900878f666..cc9861346825 100644 --- a/src/operator/upsampling.cc +++ b/src/operator/upsampling.cc @@ -54,7 +54,7 @@ Operator* UpSamplingProp::CreateOperatorEx(Context ctx, std::vector *in_ DMLC_REGISTER_PARAMETER(UpSamplingParam); MXNET_REGISTER_OP_PROPERTY(UpSampling, UpSamplingProp) -.describe("Performs nearest neighbor/bilinear up sampling to inputs") +.describe("Performs nearest neighbor/bilinear up sampling to inputs.") .add_argument("data", "NDArray-or-Symbol[]", "Array of tensors to upsample") .add_arguments(UpSamplingParam::__FIELDS__()) .set_key_var_num_args("num_args");