- MAERegressionOutput(default, default) = default
- MAERegressionOutput(default, csr) = default
By default, gradients of this loss function are scaled by factor `1/m`, where m is the number of regression outputs of a training example.
The parameter `grad_scale` can be used to change this scale to `grad_scale/m`.
Defined in C:\Jenkins\workspace\mxnet\mxnet\src\operator\regression_output.cc:L120
Declaration
public static NDArray MAERegressionOutput(NDArray data, NDArray label, float grad_scale = 1F)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | Input data to the function. |
| NDArray | label | Input label to the function. |
| System.Single | grad_scale | Scale the gradient by a float factor |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
MakeLoss(NDArray)
Make your own loss function in network construction.
This operator accepts a customized loss function NDArray as a terminal loss and
the NDArray should be an operator with no backward dependency.
The output of this function is the gradient of loss with respect to the input data.
For example, if you are a making a cross entropy loss function. Assume ``out`` is the
predicted output and ``label`` is the true label, then the cross entropy can be defined as::
cross_entropy = label * log(out) + (1 - label) * log(1 - out)
loss = make_loss(cross_entropy)
We will need to use ``make_loss`` when we are creating our own loss function or we want to
combine multiple loss functions. Also we may want to stop some variables' gradients
from backpropagation. See more detail in ``BlockGrad`` or ``stop_gradient``.
The storage type of ``make_loss`` output depends upon the input storage type:
- make_loss(default) = default
- make_loss(row_sparse) = row_sparse
Defined in C:\Jenkins\workspace\mxnet\mxnet\src\operator\tensor\elemwise_unary_op_basic.cc:L314
Declaration
public static NDArray MakeLoss(NDArray data)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | The input array. |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
MakeLoss(NDArray, Single, Single, MakelossNormalization)
Make your own loss function in network construction.
This operator accepts a customized loss function NDArray as a terminal loss and
the NDArray should be an operator with no backward dependency.
The output of this function is the gradient of loss with respect to the input data.
For example, if you are a making a cross entropy loss function. Assume ``out`` is the
predicted output and ``label`` is the true label, then the cross entropy can be defined as::
cross_entropy = label * log(out) + (1 - label) * log(1 - out)
loss = MakeLoss(cross_entropy)
We will need to use ``MakeLoss`` when we are creating our own loss function or we want to
combine multiple loss functions. Also we may want to stop some variables' gradients
from backpropagation. See more detail in ``BlockGrad`` or ``stop_gradient``.
In addition, we can give a scale to the loss by setting ``grad_scale``,
so that the gradient of the loss will be rescaled in the backpropagation.
.. note:: This operator should be used as a NDArray instead of NDArray.
Defined in C:\Jenkins\workspace\mxnet\mxnet\src\operator\make_loss.cc:L71
Declaration
public static NDArray MakeLoss(NDArray data, float grad_scale = 1F, float valid_thresh = 0F, MakelossNormalization normalization = MakelossNormalization.Null)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | Input array. |
| System.Single | grad_scale | Gradient scale as a supplement to unary and binary operators |
| System.Single | valid_thresh | clip each element in the array to 0 when it is less than |
| MakelossNormalization | normalization | If this is set to null, the output gradient will not be normalized. If this is set to batch, the output gradient will be divided by the batch size. If this is set to valid, the output gradient will be divided by the number of valid input elements. |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
Max(NDArray, Shape, Boolean, Boolean)
Computes the max of array elements over given axes.
Defined in C:\Jenkins\workspace\mxnet\mxnet\src\operator\tensor\broadcast_reduce_op_value.cc:L191
Declaration
public static NDArray Max(NDArray data, Shape axis = null, bool keepdims = false, bool exclude = false)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | The input |
| Shape | axis | The axis or axes along which to perform the reduction. The default, |
| System.Boolean | keepdims | If this is set to |
| System.Boolean | exclude | Whether to perform reduction on axis that are NOT in axis instead. |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
Maximum(NDArray, NDArray)
Declaration
public static NDArray Maximum(NDArray lhs, NDArray rhs)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | lhs | first input |
| NDArray | rhs | second input |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
MaximumScalar(NDArray, Single)
Declaration
public static NDArray MaximumScalar(NDArray data, float scalar)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | source input |
| System.Single | scalar | scalar input |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
Mean(NDArray, Shape, Boolean, Boolean)
Computes the mean of array elements over given axes.
Defined in C:\Jenkins\workspace\mxnet\mxnet\src\operator\tensor\broadcast_reduce_op_value.cc:L132
Declaration
public static NDArray Mean(NDArray data, Shape axis = null, bool keepdims = false, bool exclude = false)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | The input |
| Shape | axis | The axis or axes along which to perform the reduction. The default, |
| System.Boolean | keepdims | If this is set to |
| System.Boolean | exclude | Whether to perform reduction on axis that are NOT in axis instead. |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
Mean(NDArray, Int32, Boolean, Boolean)
Declaration
public static NDArray Mean(NDArray data, int axis, bool keepdims = false, bool exclude = false)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | |
| System.Int32 | axis | |
| System.Boolean | keepdims | |
| System.Boolean | exclude |
Returns
| Type | Description |
|---|---|
| NDArray |
Min(NDArray, Shape, Boolean, Boolean)
Computes the min of array elements over given axes.
Defined in C:\Jenkins\workspace\mxnet\mxnet\src\operator\tensor\broadcast_reduce_op_value.cc:L205
Declaration
public static NDArray Min(NDArray data, Shape axis = null, bool keepdims = false, bool exclude = false)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | The input |
| Shape | axis | The axis or axes along which to perform the reduction. The default, |
| System.Boolean | keepdims | If this is set to |
| System.Boolean | exclude | Whether to perform reduction on axis that are NOT in axis instead. |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
Minimum(NDArray, NDArray)
Declaration
public static NDArray Minimum(NDArray lhs, NDArray rhs)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | lhs | first input |
| NDArray | rhs | second input |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
MinimumScalar(NDArray, Single)
Declaration
public static NDArray MinimumScalar(NDArray data, float scalar)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | source input |
| System.Single | scalar | scalar input |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
MinusScalar(NDArray, Single)
Declaration
public static NDArray MinusScalar(NDArray data, float scalar)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | source input |
| System.Single | scalar | scalar input |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
Mod(NDArray, NDArray)
Declaration
public static NDArray Mod(NDArray lhs, NDArray rhs)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | lhs | first input |
| NDArray | rhs | second input |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
ModScalar(NDArray, Single)
Declaration
public static NDArray ModScalar(NDArray data, float scalar)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | source input |
| System.Single | scalar | scalar input |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
MpAdamwUpdate(NDArray, NDArray, NDArray, NDArray, NDArray, NDArray, Single, Single, Single, Single, Single, Single, Single)
Declaration
public static NDArray MpAdamwUpdate(NDArray weight, NDArray grad, NDArray mean, NDArray var, NDArray weight32, NDArray rescale_grad, float lr, float eta, float beta1 = 0.9F, float beta2 = 0.999F, float epsilon = 1E-08F, float wd = 0F, float clip_gradient = -1F)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | weight | |
| NDArray | grad | |
| NDArray | mean | |
| NDArray | var | |
| NDArray | weight32 | |
| NDArray | rescale_grad | |
| System.Single | lr | |
| System.Single | eta | |
| System.Single | beta1 | |
| System.Single | beta2 | |
| System.Single | epsilon | |
| System.Single | wd | |
| System.Single | clip_gradient |
Returns
| Type | Description |
|---|---|
| NDArray |
MPNAGMomUpdate(NDArray, NDArray, NDArray, NDArray, Single, Single, Single, Single, Single)
Declaration
public static NDArray MPNAGMomUpdate(NDArray weight, NDArray grad, NDArray mom, NDArray weight32, float lr, float momentum = 0F, float wd = 0F, float rescale_grad = 1F, float clip_gradient = -1F)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | weight | |
| NDArray | grad | |
| NDArray | mom | |
| NDArray | weight32 | |
| System.Single | lr | |
| System.Single | momentum | |
| System.Single | wd | |
| System.Single | rescale_grad | |
| System.Single | clip_gradient |
Returns
| Type | Description |
|---|---|
| NDArray |
MpSgdMomUpdate(NDArray, NDArray, NDArray, NDArray, Single, Single, Single, Single, Single, Boolean)
Declaration
public static NDArray MpSgdMomUpdate(NDArray weight, NDArray grad, NDArray mom, NDArray weight32, float lr, float momentum = 0F, float wd = 0F, float rescale_grad = 1F, float clip_gradient = -1F, bool lazy_update = true)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | weight | |
| NDArray | grad | |
| NDArray | mom | |
| NDArray | weight32 | |
| System.Single | lr | |
| System.Single | momentum | |
| System.Single | wd | |
| System.Single | rescale_grad | |
| System.Single | clip_gradient | |
| System.Boolean | lazy_update |
Returns
| Type | Description |
|---|---|
| NDArray |
MpSgdUpdate(NDArray, NDArray, NDArray, Single, Single, Single, Single, Boolean)
Declaration
public static NDArray MpSgdUpdate(NDArray weight, NDArray grad, NDArray weight32, float lr, float wd = 0F, float rescale_grad = 1F, float clip_gradient = -1F, bool lazy_update = true)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | weight | |
| NDArray | grad | |
| NDArray | weight32 | |
| System.Single | lr | |
| System.Single | wd | |
| System.Single | rescale_grad | |
| System.Single | clip_gradient | |
| System.Boolean | lazy_update |
Returns
| Type | Description |
|---|---|
| NDArray |
MulScalar(NDArray, Single)
Multiply an array with a scalar.
``_mul_scalar`` only operates on data array of input if input is sparse.
For example, if input of shape (100, 100) has only 2 non zero elements,
i.e. input.data = [5, 6], scalar = nan,
it will result output.data = [nan, nan] instead of 10000 nans.
Defined in C:\Jenkins\workspace\mxnet\mxnet\src\operator\tensor\elemwise_binary_scalar_op_basic.cc:L149
Declaration
public static NDArray MulScalar(NDArray data, float scalar)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | source input |
| System.Single | scalar | scalar input |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
MultiMpSgdMomUpdate(NDArrayList, Single[], Single[], Single, Single, Single, Int32, NDArrayList)
Declaration
public static NDArrayList MultiMpSgdMomUpdate(NDArrayList data, float[] lrs, float[] wds, float momentum = 0F, float rescale_grad = 1F, float clip_gradient = -1F, int num_weights = 1, NDArrayList outputs = null)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArrayList | data | |
| System.Single[] | lrs | |
| System.Single[] | wds | |
| System.Single | momentum | |
| System.Single | rescale_grad | |
| System.Single | clip_gradient | |
| System.Int32 | num_weights | |
| NDArrayList | outputs |
Returns
| Type | Description |
|---|---|
| NDArrayList |
MultiMpSgdUpdate(NDArrayList, Single[], Single[], Single, Single, Int32, NDArrayList)
Declaration
public static NDArrayList MultiMpSgdUpdate(NDArrayList data, float[] lrs, float[] wds, float rescale_grad = 1F, float clip_gradient = -1F, int num_weights = 1, NDArrayList outputs = null)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArrayList | data | |
| System.Single[] | lrs | |
| System.Single[] | wds | |
| System.Single | rescale_grad | |
| System.Single | clip_gradient | |
| System.Int32 | num_weights | |
| NDArrayList | outputs |
Returns
| Type | Description |
|---|---|
| NDArrayList |
MultiSgdMomUpdate(NDArrayList, Single[], Single[], Single, Single, Single, Int32, NDArrayList)
Declaration
public static NDArrayList MultiSgdMomUpdate(NDArrayList data, float[] lrs, float[] wds, float momentum = 0F, float rescale_grad = 1F, float clip_gradient = -1F, int num_weights = 1, NDArrayList outputs = null)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArrayList | data | |
| System.Single[] | lrs | |
| System.Single[] | wds | |
| System.Single | momentum | |
| System.Single | rescale_grad | |
| System.Single | clip_gradient | |
| System.Int32 | num_weights | |
| NDArrayList | outputs |
Returns
| Type | Description |
|---|---|
| NDArrayList |
MultiSgdUpdate(NDArrayList, Single[], Single[], Single, Single, Int32, NDArrayList)
Declaration
public static NDArrayList MultiSgdUpdate(NDArrayList data, float[] lrs, float[] wds, float rescale_grad = 1F, float clip_gradient = -1F, int num_weights = 1, NDArrayList outputs = null)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArrayList | data | |
| System.Single[] | lrs | |
| System.Single[] | wds | |
| System.Single | rescale_grad | |
| System.Single | clip_gradient | |
| System.Int32 | num_weights | |
| NDArrayList | outputs |
Returns
| Type | Description |
|---|---|
| NDArrayList |
NAGMomUpdate(NDArray, NDArray, NDArray, Single, Single, Single, Single, Single)
Declaration
public static NDArray NAGMomUpdate(NDArray weight, NDArray grad, NDArray mom, float lr, float momentum = 0F, float wd = 0F, float rescale_grad = 1F, float clip_gradient = -1F)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | weight | |
| NDArray | grad | |
| NDArray | mom | |
| System.Single | lr | |
| System.Single | momentum | |
| System.Single | wd | |
| System.Single | rescale_grad | |
| System.Single | clip_gradient |
Returns
| Type | Description |
|---|---|
| NDArray |
Nanprod(NDArray, Shape, Boolean, Boolean)
Computes the product of array elements over given axes treating Not a Numbers (``NaN``) as one.
Defined in C:\Jenkins\workspace\mxnet\mxnet\src\operator\tensor\broadcast_reduce_op_value.cc:L177
Declaration
public static NDArray Nanprod(NDArray data, Shape axis = null, bool keepdims = false, bool exclude = false)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | The input |
| Shape | axis | The axis or axes along which to perform the reduction. The default, |
| System.Boolean | keepdims | If this is set to |
| System.Boolean | exclude | Whether to perform reduction on axis that are NOT in axis instead. |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
Nansum(NDArray, Shape, Boolean, Boolean)
Computes the sum of array elements over given axes treating Not a Numbers (``NaN``) as zero.
Defined in C:\Jenkins\workspace\mxnet\mxnet\src\operator\tensor\broadcast_reduce_op_value.cc:L162
Declaration
public static NDArray Nansum(NDArray data, Shape axis = null, bool keepdims = false, bool exclude = false)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | The input |
| Shape | axis | The axis or axes along which to perform the reduction. The default, |
| System.Boolean | keepdims | If this is set to |
| System.Boolean | exclude | Whether to perform reduction on axis that are NOT in axis instead. |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
Native(NDArrayList, IntPtr, Boolean)
Stub for implementing an operator implemented in native frontend language.
Declaration
public static NDArray Native(NDArrayList data, IntPtr info, bool need_top_grad = true)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArrayList | data | Input data for the custom operator. |
| System.IntPtr | info | |
| System.Boolean | need_top_grad | Whether this layer needs out grad for backward. Should be false for loss layers. |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
Negative(NDArray)
Numerical negative of the argument, element-wise.
The storage type of ``negative`` output depends upon the input storage type:
- negative(default) = default
- negative(row_sparse) = row_sparse
- negative(csr) = csr
Declaration
public static NDArray Negative(NDArray data)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | The input array. |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
NoGradient()
Place holder for variable who cannot perform gradient
Declaration
public static NDArray NoGradient()
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
Norm(NDArray, Int32, Shape, Nullable<NormOutDtype>, Boolean)
Computes the norm on an NDArray.
This operator computes the norm on an NDArray with the specified axis, depending
on the value of the ord parameter. By default, it computes the L2 norm on the entire
array. Currently only ord=2 supports sparse ndarrays.
Examples::
x = [[[1, 2],
[3, 4]],
[[2, 2],
[5, 6]]]
norm(x, ord=2, axis=1) = [[3.1622777 4.472136 ]
[5.3851647 6.3245554]]
norm(x, ord=1, axis=1) = [[4., 6.],
[7., 8.]]
rsp = x.cast_storage('row_sparse')
norm(rsp) = [5.47722578]
csr = x.cast_storage('csr')
norm(csr) = [5.47722578]
Defined in C:\Jenkins\workspace\mxnet\mxnet\src\operator\tensor\broadcast_reduce_op_value.cc:L350
Declaration
public static NDArray Norm(NDArray data, int ord = 2, Shape axis = null, NormOutDtype? out_dtype = default(NormOutDtype? ), bool keepdims = false)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | The input |
| System.Int32 | ord | Order of the norm. Currently ord=1 and ord=2 is supported. |
| Shape | axis | The axis or axes along which to perform the reduction. The default, |
| System.Nullable<NormOutDtype> | out_dtype | The data type of the output. |
| System.Boolean | keepdims | If this is set to |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
NotEqual(NDArray, NDArray)
Declaration
public static NDArray NotEqual(NDArray lhs, NDArray rhs)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | lhs | first input |
| NDArray | rhs | second input |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
NotEqualScalar(NDArray, Single)
Declaration
public static NDArray NotEqualScalar(NDArray data, float scalar)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | source input |
| System.Single | scalar | scalar input |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
OneHot(NDArray, Int32, Double, Double, DType)
Returns a one-hot array.
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::
output[i,j,:] = off_value
output[i,j,indices[i,j]] = on_value
Examples::
one_hot([1,0,2,0], 3) = [[ 0. 1. 0.]
[ 1. 0. 0.]
[ 0. 0. 1.]
[ 1. 0. 0.]]
one_hot([1,0,2,0], 3, on_value=8, off_value=1,
dtype='int32') = [[1 8 1]
[8 1 1]
[1 1 8]
[8 1 1]]
one_hot([[1,0],[1,0],[2,0]], 3) = [[[ 0. 1. 0.]
[ 1. 0. 0.]]
[[ 0. 1. 0.]
[ 1. 0. 0.]]
[[ 0. 0. 1.]
[ 1. 0. 0.]]]
Defined in C:\Jenkins\workspace\mxnet\mxnet\src\operator\tensor\indexing_op.cc:L799
Declaration
public static NDArray OneHot(NDArray indices, int depth, double on_value = 1, double off_value = 0, DType dtype = null)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | indices | array of locations where to set on_value |
| System.Int32 | depth | Depth of the one hot dimension. |
| System.Double | on_value | The value assigned to the locations represented by indices. |
| System.Double | off_value | The value assigned to the locations not represented by indices. |
| DType | dtype | DType of the output |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
OnehotEncode(NDArray, NDArray)
Declaration
public static NDArray OnehotEncode(NDArray lhs, NDArray rhs)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | lhs | Left operand to the function. |
| NDArray | rhs | Right operand to the function. |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
Ones(Shape, Context, DType)
fill target with ones
Declaration
public static NDArray Ones(Shape shape = null, Context ctx = null, DType dtype = null)
Parameters
| Type | Name | Description |
|---|---|---|
| Shape | shape | The shape of the output |
| Context | ctx | Context of output, in format cpu|gpu|cpu_pinned.Only used for imperative calls. |
| DType | dtype | Target data type. |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
OnesLike(NDArray)
Return an array of ones with the same shape and type
as the input array.
Examples::
x = [[ 0., 0., 0.],
[ 0., 0., 0.]]
ones_like(x) = [[ 1., 1., 1.],
[ 1., 1., 1.]]
Declaration
public static NDArray OnesLike(NDArray data)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | The input |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
Pad(NDArray, PadMode, Shape, Double)
Pads an input array with a constant or edge values of the array.
.. note:: `Pad` is deprecated. Use `pad` instead.
.. note:: Current implementation only supports 4D and 5D input arrays with padding applied
only on axes 1, 2 and 3. Expects axes 4 and 5 in `pad_width` to be zero.
This operation pads an input array with either a `constant_value` or edge values
along each axis of the input array. The amount of padding is specified by `pad_width`.
`pad_width` is a tuple of integer padding widths for each axis of the format
``(before_1, after_1, ... , before_N, after_N)``. The `pad_width` should be of length ``2*N``
where ``N`` is the number of dimensions of the array.
For dimension ``N`` of the input array, ``before_N`` and ``after_N`` indicates how many values
to add before and after the elements of the array along dimension ``N``.
The widths of the higher two dimensions ``before_1``, ``after_1``, ``before_2``,
``after_2`` must be 0.
Example::
x = [[[[ 1. 2. 3.]
[ 4. 5. 6.]]
[[ 7. 8. 9.]
[ 10. 11. 12.]]]
[[[ 11. 12. 13.]
[ 14. 15. 16.]]
[[ 17. 18. 19.]
[ 20. 21. 22.]]]]
pad(x,mode="edge", pad_width=(0,0,0,0,1,1,1,1)) =
[[[[ 1. 1. 2. 3. 3.]
[ 1. 1. 2. 3. 3.]
[ 4. 4. 5. 6. 6.]
[ 4. 4. 5. 6. 6.]]
[[ 7. 7. 8. 9. 9.]
[ 7. 7. 8. 9. 9.]
[ 10. 10. 11. 12. 12.]
[ 10. 10. 11. 12. 12.]]]
[[[ 11. 11. 12. 13. 13.]
[ 11. 11. 12. 13. 13.]
[ 14. 14. 15. 16. 16.]
[ 14. 14. 15. 16. 16.]]
[[ 17. 17. 18. 19. 19.]
[ 17. 17. 18. 19. 19.]
[ 20. 20. 21. 22. 22.]
[ 20. 20. 21. 22. 22.]]]]
pad(x, mode="constant", constant_value=0, pad_width=(0,0,0,0,1,1,1,1)) =
[[[[ 0. 0. 0. 0. 0.]
[ 0. 1. 2. 3. 0.]
[ 0. 4. 5. 6. 0.]
[ 0. 0. 0. 0. 0.]]
[[ 0. 0. 0. 0. 0.]
[ 0. 7. 8. 9. 0.]
[ 0. 10. 11. 12. 0.]
[ 0. 0. 0. 0. 0.]]]
[[[ 0. 0. 0. 0. 0.]
[ 0. 11. 12. 13. 0.]
[ 0. 14. 15. 16. 0.]
[ 0. 0. 0. 0. 0.]]
[[ 0. 0. 0. 0. 0.]
[ 0. 17. 18. 19. 0.]
[ 0. 20. 21. 22. 0.]
[ 0. 0. 0. 0. 0.]]]]
Defined in C:\Jenkins\workspace\mxnet\mxnet\src\operator\pad.cc:L766
Declaration
public static NDArray Pad(NDArray data, PadMode mode, Shape pad_width, double constant_value = 0)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | An n-dimensional input array. |
| PadMode | mode | Padding type to use. "constant" pads with |
| Shape | pad_width | Widths of the padding regions applied to the edges of each axis. It is a tuple of integer
padding widths for each axis of the format |
| System.Double | constant_value | The value used for padding when |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
Pick(NDArray, NDArray, Nullable<Int32>, Boolean, PickMode)
Picks elements from an input array according to the input indices along the given axis.
Given an input array of shape ``(d0, d1)`` and indices of shape ``(i0,)``, the result will be
an output array of shape ``(i0,)`` with::
output[i] = input[i, indices[i]]
By default, if any index mentioned is too large, it is replaced by the index that addresses
the last element along an axis (the `clip` mode).
This function supports n-dimensional input and (n-1)-dimensional indices arrays.
Examples::
x = [[ 1., 2.],
[ 3., 4.],
[ 5., 6.]]
// picks elements with specified indices along axis 0
pick(x, y=[0,1], 0) = [ 1., 4.]
// picks elements with specified indices along axis 1
pick(x, y=[0,1,0], 1) = [ 1., 4., 5.]
y = [[ 1.],
[ 0.],
[ 2.]]
// picks elements with specified indices along axis 1 using 'wrap' mode
// to place indicies that would normally be out of bounds
pick(x, y=[2,-1,-2], 1, mode='wrap') = [ 1., 4., 5.]
y = [[ 1.],
[ 0.],
[ 2.]]
// picks elements with specified indices along axis 1 and dims are maintained
pick(x,y, 1, keepdims=True) = [[ 2.],
[ 3.],
[ 6.]]
Defined in C:\Jenkins\workspace\mxnet\mxnet\src\operator\tensor\broadcast_reduce_op_index.cc:L154
Declaration
public static NDArray Pick(NDArray data, NDArray index, int? axis, bool keepdims = false, PickMode mode = PickMode.Clip)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | The input array |
| NDArray | index | The index array |
| System.Nullable<System.Int32> | axis | int or None. The axis to picking the elements. Negative values means indexing from right to left. If
is |
| System.Boolean | keepdims | If true, the axis where we pick the elements is left in the result as dimension with size one. |
| PickMode | mode | Specify how out-of-bound indices behave. Default is "clip". "clip" means clip to the range. So, if all indices mentioned are too large, they are replaced by the index that addresses the last element along an axis. "wrap" means to wrap around. |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
PlusScalar(NDArray, Single)
Declaration
public static NDArray PlusScalar(NDArray data, float scalar)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | source input |
| System.Single | scalar | scalar input |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
Pooling(NDArray, Shape, PoolingType, Boolean, Boolean, PoolingConvention, Shape, Shape, Nullable<Int32>, Nullable<Boolean>, String)
Performs pooling on the input.
The shapes for 1-D pooling are
- **data** and **out**: *(batch_size, channel, width)* (NCW layout) or
*(batch_size, width, channel)* (NWC layout),
The shapes for 2-D pooling are
- **data** and **out**: *(batch_size, channel, height, width)* (NCHW layout) or
*(batch_size, height, width, channel)* (NHWC layout),
out_height = f(height, kernel[0], pad[0], stride[0])
out_width = f(width, kernel[1], pad[1], stride[1])
The definition of *f* depends on ``pooling_convention``, which has two options:
- **valid** (default)::
f(x, k, p, s) = floor((x+2*p-k)/s)+1
- **full**, which is compatible with Caffe::
f(x, k, p, s) = ceil((x+2*p-k)/s)+1
But ``global_pool`` is set to be true, then do a global pooling, namely reset
``kernel=(height, width)``.
Three pooling options are supported by ``pool_type``:
- **avg**: average pooling
- **max**: max pooling
- **sum**: sum pooling
- **lp**: Lp pooling
For 3-D pooling, an additional *depth* dimension is added before
*height*. Namely the input data and output will have shape *(batch_size, channel, depth,
height, width)* (NCDHW layout) or *(batch_size, depth, height, width, channel)* (NDHWC layout).
Notes on Lp pooling:
Lp pooling was first introduced by this paper: https://arxiv.org/pdf/1204.3968.pdf.
L-1 pooling is simply sum pooling, while L-inf pooling is simply max pooling.
We can see that Lp pooling stands between those two, in practice the most common value for p is 2.
For each window ``X``, the mathematical expression for Lp pooling is:
:math:`f(X) = \sqrt[p]{\sum_{x}^{X} x^p}`
Defined in C:\Jenkins\workspace\mxnet\mxnet\src\operator\nn\pooling.cc:L416
Declaration
public static NDArray Pooling(NDArray data, Shape kernel = null, PoolingType pool_type = PoolingType.Max, bool global_pool = false, bool cudnn_off = false, PoolingConvention pooling_convention = PoolingConvention.Valid, Shape stride = null, Shape pad = null, int? p_value = default(int? ), bool? count_include_pad = default(bool? ), string layout = null)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | Input data to the pooling operator. |
| Shape | kernel | Pooling kernel size: (y, x) or (d, y, x) |
| PoolingType | pool_type | Pooling type to be applied. |
| System.Boolean | global_pool | Ignore kernel size, do global pooling based on current input feature map. |
| System.Boolean | cudnn_off | Turn off cudnn pooling and use MXNet pooling operator. |
| PoolingConvention | pooling_convention | Pooling convention to be applied. |
| Shape | stride | Stride: for pooling (y, x) or (d, y, x). Defaults to 1 for each dimension. |
| Shape | pad | Pad for pooling: (y, x) or (d, y, x). Defaults to no padding. |
| System.Nullable<System.Int32> | p_value | Value of p for Lp pooling, can be 1 or 2, required for Lp Pooling. |
| System.Nullable<System.Boolean> | count_include_pad | Only used for AvgPool, specify whether to count padding elements for averagecalculation. For example, with a 55 kernel on a 33 corner of a image,the sum of the 9 valid elements will be divided by 25 if this is set to true,or it will be divided by 9 if this is set to false. Defaults to true. |
| System.String | layout | Set layout for input and output. Empty for default layout: NCW for 1d, NCHW for 2d and NCDHW for 3d. |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
PoolingV1(NDArray, Shape, PoolingV1PoolType, Boolean, PoolingV1PoolingConvention, Shape, Shape)
This operator is DEPRECATED.
Perform pooling on the input.
The shapes for 2-D pooling is
- **data**: *(batch_size, channel, height, width)*
- **out**: *(batch_size, num_filter, out_height, out_width)*, with::
out_height = f(height, kernel[0], pad[0], stride[0])
out_width = f(width, kernel[1], pad[1], stride[1])
The definition of *f* depends on ``pooling_convention``, which has two options:
- **valid** (default)::
f(x, k, p, s) = floor((x+2*p-k)/s)+1
- **full**, which is compatible with Caffe::
f(x, k, p, s) = ceil((x+2*p-k)/s)+1
But ``global_pool`` is set to be true, then do a global pooling, namely reset
``kernel=(height, width)``.
Three pooling options are supported by ``pool_type``:
- **avg**: average pooling
- **max**: max pooling
- **sum**: sum pooling
1-D pooling is special case of 2-D pooling with *weight=1* and
*kernel[1]=1*.
For 3-D pooling, an additional *depth* dimension is added before
*height*. Namely the input data will have shape *(batch_size, channel, depth,
height, width)*.
Defined in C:\Jenkins\workspace\mxnet\mxnet\src\operator\pooling_v1.cc:L104
Declaration
public static NDArray PoolingV1(NDArray data, Shape kernel = null, PoolingV1PoolType pool_type = PoolingV1PoolType.Max, bool global_pool = false, PoolingV1PoolingConvention pooling_convention = PoolingV1PoolingConvention.Valid, Shape stride = null, Shape pad = null)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | Input data to the pooling operator. |
| Shape | kernel | pooling kernel size: (y, x) or (d, y, x) |
| PoolingV1PoolType | pool_type | Pooling type to be applied. |
| System.Boolean | global_pool | Ignore kernel size, do global pooling based on current input feature map. |
| PoolingV1PoolingConvention | pooling_convention | Pooling convention to be applied. |
| Shape | stride | stride: for pooling (y, x) or (d, y, x) |
| Shape | pad | pad for pooling: (y, x) or (d, y, x) |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
Power(NDArray, NDArray)
Declaration
public static NDArray Power(NDArray lhs, NDArray rhs)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | lhs | first input |
| NDArray | rhs | second input |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
PowerScalar(NDArray, Single)
Declaration
public static NDArray PowerScalar(NDArray data, float scalar)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | source input |
| System.Single | scalar | scalar input |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
Prod(NDArray, Shape, Boolean, Boolean)
Computes the product of array elements over given axes.
Defined in C:\Jenkins\workspace\mxnet\mxnet\src\operator\tensor\broadcast_reduce_op_value.cc:L147
Declaration
public static NDArray Prod(NDArray data, Shape axis = null, bool keepdims = false, bool exclude = false)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | The input |
| Shape | axis | The axis or axes along which to perform the reduction. The default, |
| System.Boolean | keepdims | If this is set to |
| System.Boolean | exclude | Whether to perform reduction on axis that are NOT in axis instead. |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
Radians(NDArray)
Converts each element of the input array from degrees to radians.
.. math::
radians([0, 90, 180, 270, 360]) = [0, \pi/2, \pi, 3\pi/2, 2\pi]
The storage type of ``radians`` output depends upon the input storage type:
- radians(default) = default
- radians(row_sparse) = row_sparse
- radians(csr) = csr
Defined in C:\Jenkins\workspace\mxnet\mxnet\src\operator\tensor\elemwise_unary_op_trig.cc:L182
Declaration
public static NDArray Radians(NDArray data)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | The input array. |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
RavelMultiIndex(NDArray, Shape)
Converts a batch of index arrays into an array of flat indices. The operator follows numpy conventions so a single multi index is given by a column of the input matrix. The leading dimension may be left unspecified by using -1 as placeholder.
Examples::
A = [[3,6,6],[4,5,1]]
ravel(A, shape=(7,6)) = [22,41,37]
ravel(A, shape=(-1,6)) = [22,41,37]
Defined in C:\Jenkins\workspace\mxnet\mxnet\src\operator\tensor\ravel.cc:L42
Declaration
public static NDArray RavelMultiIndex(NDArray data, Shape shape = null)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | Batch of multi-indices |
| Shape | shape | Shape of the array into which the multi-indices apply. |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
Rcbrt(NDArray)
Returns element-wise inverse cube-root value of the input.
.. math::
rcbrt(x) = 1/\sqrt[3]{x}
Example::
rcbrt([1,8,-125]) = [1.0, 0.5, -0.2]
Defined in C:\Jenkins\workspace\mxnet\mxnet\src\operator\tensor\elemwise_unary_op_basic.cc:L955
Declaration
public static NDArray Rcbrt(NDArray data)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | The input array. |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
RdivScalar(NDArray, Single)
Declaration
public static NDArray RdivScalar(NDArray data, float scalar)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | source input |
| System.Single | scalar | scalar input |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
Reciprocal(NDArray)
Returns the reciprocal of the argument, element-wise.
Calculates 1/x.
Example::
reciprocal([-2, 1, 3, 1.6, 0.2]) = [-0.5, 1.0, 0.33333334, 0.625, 5.0]
Defined in C:\Jenkins\workspace\mxnet\mxnet\src\operator\tensor\elemwise_unary_op_basic.cc:L663
Declaration
public static NDArray Reciprocal(NDArray data)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | The input array. |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
Relu(NDArray)
Computes rectified linear activation.
.. math::
max(features, 0)
The storage type of ``relu`` output depends upon the input storage type:
- relu(default) = default
- relu(row_sparse) = row_sparse
- relu(csr) = csr
Defined in C:\Jenkins\workspace\mxnet\mxnet\src\operator\tensor\elemwise_unary_op_basic.cc:L85
Declaration
public static NDArray Relu(NDArray data)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | The input array. |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
Repeat(NDArray, Int32, Nullable<Int32>)
Repeats elements of an array.
By default, ``repeat`` flattens the input array into 1-D and then repeats the
elements::
x = [[ 1, 2],
[ 3, 4]]
repeat(x, repeats=2) = [ 1., 1., 2., 2., 3., 3., 4., 4.]
The parameter ``axis`` specifies the axis along which to perform repeat::
repeat(x, repeats=2, axis=1) = [[ 1., 1., 2., 2.],
[ 3., 3., 4., 4.]]
repeat(x, repeats=2, axis=0) = [[ 1., 2.],
[ 1., 2.],
[ 3., 4.],
[ 3., 4.]]
repeat(x, repeats=2, axis=-1) = [[ 1., 1., 2., 2.],
[ 3., 3., 4., 4.]]
Defined in C:\Jenkins\workspace\mxnet\mxnet\src\operator\tensor\matrix_op.cc:L820
Declaration
public static NDArray Repeat(NDArray data, int repeats, int? axis = default(int? ))
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | Input data array |
| System.Int32 | repeats | The number of repetitions for each element. |
| System.Nullable<System.Int32> | axis | The axis along which to repeat values. The negative numbers are interpreted counting from the backward. By default, use the flattened input array, and return a flat output array. |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
Reshape(NDArray, Shape, Boolean)
Reshapes the input array.
.. note:: ``Reshape`` is deprecated, use ``reshape``
Given an array and a shape, this function returns a copy of the array in the new shape.
The shape is a tuple of integers such as (2,3,4). The size of the new shape should be same as the size of the input array.
Example::
reshape([1,2,3,4], shape=(2,2)) = [[1,2], [3,4]]
Some dimensions of the shape can take special values from the set {0, -1, -2, -3, -4}. The significance of each is explained below:
- ``0`` copy this dimension from the input to the output shape.
Example::
- input shape = (2,3,4), shape = (4,0,2), output shape = (4,3,2)
- input shape = (2,3,4), shape = (2,0,0), output shape = (2,3,4)
- ``-1`` infers the dimension of the output shape by using the remainder of the input dimensions
keeping the size of the new array same as that of the input array.
At most one dimension of shape can be -1.
Example::
- input shape = (2,3,4), shape = (6,1,-1), output shape = (6,1,4)
- input shape = (2,3,4), shape = (3,-1,8), output shape = (3,1,8)
- input shape = (2,3,4), shape=(-1,), output shape = (24,)
- ``-2`` copy all/remainder of the input dimensions to the output shape.
Example::
- input shape = (2,3,4), shape = (-2,), output shape = (2,3,4)
- input shape = (2,3,4), shape = (2,-2), output shape = (2,3,4)
- input shape = (2,3,4), shape = (-2,1,1), output shape = (2,3,4,1,1)
- ``-3`` use the product of two consecutive dimensions of the input shape as the output dimension.
Example::
- input shape = (2,3,4), shape = (-3,4), output shape = (6,4)
- input shape = (2,3,4,5), shape = (-3,-3), output shape = (6,20)
- input shape = (2,3,4), shape = (0,-3), output shape = (2,12)
- input shape = (2,3,4), shape = (-3,-2), output shape = (6,4)
- ``-4`` split one dimension of the input into two dimensions passed subsequent to -4 in shape (can contain -1).
Example::
- input shape = (2,3,4), shape = (-4,1,2,-2), output shape =(1,2,3,4)
- input shape = (2,3,4), shape = (2,-4,-1,3,-2), output shape = (2,1,3,4)
If the argument `reverse` is set to 1, then the special values are inferred from right to left.
Example::
- without reverse=1, for input shape = (10,5,4), shape = (-1,0), output shape would be (40,5)
- with reverse=1, output shape will be (50,4).
Defined in C:\Jenkins\workspace\mxnet\mxnet\src\operator\tensor\matrix_op.cc:L222
Declaration
public static NDArray Reshape(NDArray data, Shape shape = null, bool reverse = false)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | Input data to reshape. |
| Shape | shape | The target shape |
| System.Boolean | reverse | If true then the special values are inferred from right to left |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
ReshapeLike(NDArray, NDArray)
Reshape some or all dimensions of `lhs` to have the same shape as some or all dimensions of `rhs`.
Returns a **view** of the `lhs` array with a new shape without altering any data.
Example::
x = [1, 2, 3, 4, 5, 6]
y = [[0, -4], [3, 2], [2, 2]]
reshape_like(x, y) = [[1, 2], [3, 4], [5, 6]]
More precise control over how dimensions are inherited is achieved by specifying \
slices over the `lhs` and `rhs` array dimensions. Only the sliced `lhs` dimensions \
are reshaped to the `rhs` sliced dimensions, with the non-sliced `lhs` dimensions staying the same.
Examples::
- lhs shape = (30,7), rhs shape = (15,2,4), lhs_begin=0, lhs_end=1, rhs_begin=0, rhs_end=2, output shape = (15,2,7)
- lhs shape = (3, 5), rhs shape = (1,15,4), lhs_begin=0, lhs_end=2, rhs_begin=1, rhs_end=2, output shape = (15)
Negative indices are supported, and `None` can be used for either `lhs_end` or `rhs_end` to indicate the end of the range.
Example::
- lhs shape = (30, 12), rhs shape = (4, 2, 2, 3), lhs_begin=-1, lhs_end=None, rhs_begin=1, rhs_end=None, output shape = (30, 2, 2, 3)
Defined in C:\Jenkins\workspace\mxnet\mxnet\src\operator\tensor\elemwise_unary_op_basic.cc:L469
Declaration
public static NDArray ReshapeLike(NDArray lhs, NDArray rhs)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | lhs | First input. |
| NDArray | rhs | Second input. |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
Reverse(NDArray, Shape)
Reverses the order of elements along given axis while preserving array shape.
Note: reverse and flip are equivalent. We use reverse in the following examples.
Examples::
x = [[ 0., 1., 2., 3., 4.],
[ 5., 6., 7., 8., 9.]]
reverse(x, axis=0) = [[ 5., 6., 7., 8., 9.],
[ 0., 1., 2., 3., 4.]]
reverse(x, axis=1) = [[ 4., 3., 2., 1., 0.],
[ 9., 8., 7., 6., 5.]]
Defined in C:\Jenkins\workspace\mxnet\mxnet\src\operator\tensor\matrix_op.cc:L922
Declaration
public static NDArray Reverse(NDArray data, Shape axis)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | Input data array |
| Shape | axis | The axis which to reverse elements. |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
Rint(NDArray)
Returns element-wise rounded value to the nearest integer of the input.
.. note::
- For input ``n.5`` ``rint`` returns ``n`` while ``round`` returns ``n+1``.
- For input ``-n.5`` both ``rint`` and ``round`` returns ``-n-1``.
Example::
rint([-1.5, 1.5, -1.9, 1.9, 2.1]) = [-2., 1., -2., 2., 2.]
The storage type of ``rint`` output depends upon the input storage type:
- rint(default) = default
- rint(row_sparse) = row_sparse
- rint(csr) = csr
Defined in C:\Jenkins\workspace\mxnet\mxnet\src\operator\tensor\elemwise_unary_op_basic.cc:L744
Declaration
public static NDArray Rint(NDArray data)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | The input array. |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
RminusScalar(NDArray, Single)
Declaration
public static NDArray RminusScalar(NDArray data, float scalar)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | source input |
| System.Single | scalar | scalar input |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
RmodScalar(NDArray, Single)
Declaration
public static NDArray RmodScalar(NDArray data, float scalar)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | source input |
| System.Single | scalar | scalar input |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
RmspropalexUpdate(NDArray, NDArray, NDArray, NDArray, NDArray, Single, Single, Single, Single, Single, Single, Single, Single)
Declaration
public static NDArray RmspropalexUpdate(NDArray weight, NDArray grad, NDArray n, NDArray g, NDArray delta, float lr, float gamma1 = 0.95F, float gamma2 = 0.9F, float epsilon = 1E-08F, float wd = 0F, float rescale_grad = 1F, float clip_gradient = -1F, float clip_weights = -1F)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | weight | |
| NDArray | grad | |
| NDArray | n | |
| NDArray | g | |
| NDArray | delta | |
| System.Single | lr | |
| System.Single | gamma1 | |
| System.Single | gamma2 | |
| System.Single | epsilon | |
| System.Single | wd | |
| System.Single | rescale_grad | |
| System.Single | clip_gradient | |
| System.Single | clip_weights |
Returns
| Type | Description |
|---|---|
| NDArray |
RmspropUpdate(NDArray, NDArray, NDArray, Single, Single, Single, Single, Single, Single, Single)
Declaration
public static NDArray RmspropUpdate(NDArray weight, NDArray grad, NDArray n, float lr, float gamma1 = 0.95F, float epsilon = 1E-08F, float wd = 0F, float rescale_grad = 1F, float clip_gradient = -1F, float clip_weights = -1F)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | weight | |
| NDArray | grad | |
| NDArray | n | |
| System.Single | lr | |
| System.Single | gamma1 | |
| System.Single | epsilon | |
| System.Single | wd | |
| System.Single | rescale_grad | |
| System.Single | clip_gradient | |
| System.Single | clip_weights |
Returns
| Type | Description |
|---|---|
| NDArray |
RNN(NDArray, NDArray, NDArray, NDArray, UInt32, UInt32, RNNMode, Boolean, Single, Boolean, Nullable<Int32>, Nullable<Double>, Nullable<Double>, Boolean)
Applies recurrent layers to input data. Currently, vanilla RNN, LSTM and GRU are
implemented, with both multi-layer and bidirectional support.
When the input data is of type float32 and the environment variables MXNET_CUDA_ALLOW_TENSOR_CORE
and MXNET_CUDA_TENSOR_OP_MATH_ALLOW_CONVERSION are set to 1, this operator will try to use
pseudo-float16 precision (float32 math with float16 I/O) precision in order to use
Tensor Cores on suitable NVIDIA GPUs. This can sometimes give significant speedups.
**Vanilla RNN**
Applies a single-gate recurrent layer to input X. Two kinds of activation function are supported:
ReLU and Tanh.
With ReLU activation function:
.. math::
h_t = relu(W_{ih} * x_t + b_{ih} + W_{hh} * h_{(t-1)} + b_{hh})
With Tanh activtion function:
.. math::
h_t = \tanh(W_{ih} * x_t + b_{ih} + W_{hh} * h_{(t-1)} + b_{hh})
Reference paper: Finding structure in time - Elman, 1988.
https://crl.ucsd.edu/~elman/Papers/fsit.pdf
**LSTM**
Long Short-Term Memory - Hochreiter, 1997. http://www.bioinf.jku.at/publications/older/2604.pdf
.. math::
\begin{array}{ll}
i_t = \mathrm{sigmoid}(W_{ii} x_t + b_{ii} + W_{hi} h_{(t-1)} + b_{hi}) \\
f_t = \mathrm{sigmoid}(W_{if} x_t + b_{if} + W_{hf} h_{(t-1)} + b_{hf}) \\
g_t = \tanh(W_{ig} x_t + b_{ig} + W_{hc} h_{(t-1)} + b_{hg}) \\
o_t = \mathrm{sigmoid}(W_{io} x_t + b_{io} + W_{ho} h_{(t-1)} + b_{ho}) \\
c_t = f_t * c_{(t-1)} + i_t * g_t \\
h_t = o_t * \tanh(c_t)
\end{array}
**GRU**
Gated Recurrent Unit - Cho et al. 2014. http://arxiv.org/abs/1406.1078
The definition of GRU here is slightly different from paper but compatible with CUDNN.
.. math::
\begin{array}{ll}
r_t = \mathrm{sigmoid}(W_{ir} x_t + b_{ir} + W_{hr} h_{(t-1)} + b_{hr}) \\
z_t = \mathrm{sigmoid}(W_{iz} x_t + b_{iz} + W_{hz} h_{(t-1)} + b_{hz}) \\
n_t = \tanh(W_{in} x_t + b_{in} + r_t * (W_{hn} h_{(t-1)}+ b_{hn})) \\
h_t = (1 - z_t) * n_t + z_t * h_{(t-1)} \\
\end{array}
Defined in C:\Jenkins\workspace\mxnet\mxnet\src\operator\rnn.cc:L219
Declaration
public static NDArray RNN(NDArray data, NDArray parameters, NDArray state, NDArray state_cell, uint state_size, uint num_layers, RNNMode mode, bool bidirectional = false, float p = 0F, bool state_outputs = false, int? projection_size = default(int? ), double? lstm_state_clip_min = default(double? ), double? lstm_state_clip_max = default(double? ), bool lstm_state_clip_nan = false)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | Input data to RNN |
| NDArray | parameters | Vector of all RNN trainable parameters concatenated |
| NDArray | state | initial hidden state of the RNN |
| NDArray | state_cell | initial cell state for LSTM networks (only for LSTM) |
| System.UInt32 | state_size | size of the state for each layer |
| System.UInt32 | num_layers | number of stacked layers |
| RNNMode | mode | the type of RNN to compute |
| System.Boolean | bidirectional | whether to use bidirectional recurrent layers |
| System.Single | p | drop rate of the dropout on the outputs of each RNN layer, except the last layer. |
| System.Boolean | state_outputs | Whether to have the states as NDArray outputs. |
| System.Nullable<System.Int32> | projection_size | size of project size |
| System.Nullable<System.Double> | lstm_state_clip_min | Minimum clip value of LSTM states. This option must be used together with lstm_state_clip_max. |
| System.Nullable<System.Double> | lstm_state_clip_max | Maximum clip value of LSTM states. This option must be used together with lstm_state_clip_min. |
| System.Boolean | lstm_state_clip_nan | Whether to stop NaN from propagating in state by clipping it to min/max. If clipping range is not specified, this option is ignored. |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
RnnParamConcat(NDArrayList, Int32, Int32)
Declaration
public static NDArray RnnParamConcat(NDArrayList data, int num_args, int dim = 1)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArrayList | data | List of arrays to concatenate |
| System.Int32 | num_args | Number of inputs to be concated. |
| System.Int32 | dim | the dimension to be concated. |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
ROIPooling(NDArray, NDArray, Shape, Single)
Performs region of interest(ROI) pooling on the input array.
ROI pooling is a variant of a max pooling layer, in which the output size is fixed and
region of interest is a parameter. Its purpose is to perform max pooling on the inputs
of non-uniform sizes to obtain fixed-size feature maps. ROI pooling is a neural-net
layer mostly used in training a `Fast R-CNN` network for object detection.
This operator takes a 4D feature map as an input array and region proposals as `rois`,
then it pools over sub-regions of input and produces a fixed-sized output array
regardless of the ROI size.
To crop the feature map accordingly, you can resize the bounding box coordinates
by changing the parameters `rois` and `spatial_scale`.
The cropped feature maps are pooled by standard max pooling operation to a fixed size output
indicated by a `pooled_size` parameter. batch_size will change to the number of region
bounding boxes after `ROIPooling`.
The size of each region of interest doesn't have to be perfectly divisible by
the number of pooling sections(`pooled_size`).
Example::
x = [[[[ 0., 1., 2., 3., 4., 5.],
[ 6., 7., 8., 9., 10., 11.],
[ 12., 13., 14., 15., 16., 17.],
[ 18., 19., 20., 21., 22., 23.],
[ 24., 25., 26., 27., 28., 29.],
[ 30., 31., 32., 33., 34., 35.],
[ 36., 37., 38., 39., 40., 41.],
[ 42., 43., 44., 45., 46., 47.]]]]
// region of interest i.e. bounding box coordinates.
y = [[0,0,0,4,4]]
// returns array of shape (2,2) according to the given roi with max pooling.
ROIPooling(x, y, (2,2), 1.0) = [[[[ 14., 16.],
[ 26., 28.]]]]
// region of interest is changed due to the change in `spacial_scale` parameter.
ROIPooling(x, y, (2,2), 0.7) = [[[[ 7., 9.],
[ 19., 21.]]]]
Defined in C:\Jenkins\workspace\mxnet\mxnet\src\operator\roi_pooling.cc:L295
Declaration
public static NDArray ROIPooling(NDArray data, NDArray rois, Shape pooled_size, float spatial_scale)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | The input array to the pooling operator, a 4D Feature maps |
| NDArray | rois | Bounding box coordinates, a 2D array of [[batch_index, x1, y1, x2, y2]], where (x1, y1) and (x2, y2)
are top left and bottom right corners of designated region of interest. |
| Shape | pooled_size | ROI pooling output shape (h,w) |
| System.Single | spatial_scale | Ratio of input feature map height (or w) to raw image height (or w). Equals the reciprocal of total stride in convolutional layers |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
Round(NDArray)
Returns element-wise rounded value to the nearest integer of the input.
Example::
round([-1.5, 1.5, -1.9, 1.9, 2.1]) = [-2., 2., -2., 2., 2.]
The storage type of ``round`` output depends upon the input storage type:
- round(default) = default
- round(row_sparse) = row_sparse
- round(csr) = csr
Defined in C:\Jenkins\workspace\mxnet\mxnet\src\operator\tensor\elemwise_unary_op_basic.cc:L723
Declaration
public static NDArray Round(NDArray data)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | The input array. |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
RpowerScalar(NDArray, Single)
Declaration
public static NDArray RpowerScalar(NDArray data, float scalar)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | source input |
| System.Single | scalar | scalar input |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
Rsqrt(NDArray)
Returns element-wise inverse square-root value of the input.
.. math::
rsqrt(x) = 1/\sqrt{x}
Example::
rsqrt([4,9,16]) = [0.5, 0.33333334, 0.25]
The storage type of ``rsqrt`` output is always dense
Defined in C:\Jenkins\workspace\mxnet\mxnet\src\operator\tensor\elemwise_unary_op_basic.cc:L883
Declaration
public static NDArray Rsqrt(NDArray data)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | The input array. |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
SampleExponential(NDArray, Shape, DType)
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
operator is not set, then one sample will be drawn per distribution and the output array
has the same shape as the input array.
Examples::
lam = [ 1.0, 8.5 ]
// Draw a single sample for each distribution
sample_exponential(lam) = [ 0.51837951, 0.09994757]
// Draw a vector containing two samples for each distribution
sample_exponential(lam, shape=(2)) = [[ 0.51837951, 0.19866663],
[ 0.09994757, 0.50447971]]
Defined in C:\Jenkins\workspace\mxnet\mxnet\src\operator\random\multisample_op.cc:L284
Declaration
public static NDArray SampleExponential(NDArray lam, Shape shape = null, DType dtype = null)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | lam | Lambda (rate) parameters of the distributions. |
| Shape | shape | Shape to be sampled from each random distribution. |
| DType | dtype | DType of the output in case this can't be inferred. Defaults to float32 if not defined (dtype=None). |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
SampleGamma(NDArray, NDArray, Shape, DType)
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
operator is not set, then one sample will be drawn per distribution and the output array
has the same shape as the input arrays.
Examples::
alpha = [ 0.0, 2.5 ]
beta = [ 1.0, 0.7 ]
// Draw a single sample for each distribution
sample_gamma(alpha, beta) = [ 0. , 2.25797319]
// Draw a vector containing two samples for each distribution
sample_gamma(alpha, beta, shape=(2)) = [[ 0. , 0. ],
[ 2.25797319, 1.70734084]]
Defined in C:\Jenkins\workspace\mxnet\mxnet\src\operator\random\multisample_op.cc:L282
Declaration
public static NDArray SampleGamma(NDArray alpha, NDArray beta, Shape shape = null, DType dtype = null)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | alpha | Alpha (shape) parameters of the distributions. |
| NDArray | beta | Beta (scale) parameters of the distributions. |
| Shape | shape | Shape to be sampled from each random distribution. |
| DType | dtype | DType of the output in case this can't be inferred. Defaults to float32 if not defined (dtype=None). |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
SampleGeneralizedNegativeBinomial(NDArray, NDArray, Shape, DType)
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
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::
mu = [ 2.0, 2.5 ]
alpha = [ 1.0, 0.1 ]
// Draw a single sample for each distribution
sample_generalized_negative_binomial(mu, alpha) = [ 0., 3.]
// Draw a vector containing two samples for each distribution
sample_generalized_negative_binomial(mu, alpha, shape=(2)) = [[ 0., 3.],
[ 3., 1.]]
Defined in C:\Jenkins\workspace\mxnet\mxnet\src\operator\random\multisample_op.cc:L293
Declaration
public static NDArray SampleGeneralizedNegativeBinomial(NDArray mu, NDArray alpha, Shape shape = null, DType dtype = null)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | mu | Means of the distributions. |
| NDArray | alpha | Alpha (dispersion) parameters of the distributions. |
| Shape | shape | Shape to be sampled from each random distribution. |
| DType | dtype | DType of the output in case this can't be inferred. Defaults to float32 if not defined (dtype=None). |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
SampleMultinomial(NDArray, Shape, Boolean, DType)
Concurrent sampling from multiple multinomial distributions.
*data* is an *n* dimensional array whose last dimension has length *k*, where
*k* is the number of possible outcomes of each multinomial distribution. This
operator will draw *shape* samples from each distribution. If shape is empty
one sample will be drawn from each distribution.
If *get_prob* is true, a second array containing log likelihood of the drawn
samples will also be returned. This is usually used for reinforcement learning
where you can provide reward as head gradient for this array to estimate
gradient.
Note that the input distribution must be normalized, i.e. *data* must sum to
1 along its last axis.
Examples::
probs = [[0, 0.1, 0.2, 0.3, 0.4], [0.4, 0.3, 0.2, 0.1, 0]]
// Draw a single sample for each distribution
sample_multinomial(probs) = [3, 0]
// Draw a vector containing two samples for each distribution
sample_multinomial(probs, shape=(2)) = [[4, 2],
[0, 0]]
// requests log likelihood
sample_multinomial(probs, get_prob=True) = [2, 1], [0.2, 0.3]
Declaration
public static NDArray SampleMultinomial(NDArray data, Shape shape = null, bool get_prob = false, DType dtype = null)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | Distribution probabilities. Must sum to one on the last axis. |
| Shape | shape | Shape to be sampled from each random distribution. |
| System.Boolean | get_prob | Whether to also return the log probability of sampled result. This is usually used for differentiating through stochastic variables, e.g. in reinforcement learning. |
| DType | dtype | DType of the output in case this can't be inferred. |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
SampleNegativeBinomial(NDArray, NDArray, Shape, DType)
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
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::
k = [ 20, 49 ]
p = [ 0.4 , 0.77 ]
// Draw a single sample for each distribution
sample_negative_binomial(k, p) = [ 15., 16.]
// Draw a vector containing two samples for each distribution
sample_negative_binomial(k, p, shape=(2)) = [[ 15., 50.],
[ 16., 12.]]
Defined in C:\Jenkins\workspace\mxnet\mxnet\src\operator\random\multisample_op.cc:L289
Declaration
public static NDArray SampleNegativeBinomial(NDArray k, NDArray p, Shape shape = null, DType dtype = null)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | k | Limits of unsuccessful experiments. |
| NDArray | p | Failure probabilities in each experiment. |
| Shape | shape | Shape to be sampled from each random distribution. |
| DType | dtype | DType of the output in case this can't be inferred. Defaults to float32 if not defined (dtype=None). |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
SampleNormal(NDArray, NDArray, Shape, DType)
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
operator is not set, then one sample will be drawn per distribution and the output array
has the same shape as the input arrays.
Examples::
mu = [ 0.0, 2.5 ]
sigma = [ 1.0, 3.7 ]
// Draw a single sample for each distribution
sample_normal(mu, sigma) = [-0.56410581, 0.95934606]
// Draw a vector containing two samples for each distribution
sample_normal(mu, sigma, shape=(2)) = [[-0.56410581, 0.2928229 ],
[ 0.95934606, 4.48287058]]
Defined in C:\Jenkins\workspace\mxnet\mxnet\src\operator\random\multisample_op.cc:L279
Declaration
public static NDArray SampleNormal(NDArray mu, NDArray sigma, Shape shape = null, DType dtype = null)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | mu | Means of the distributions. |
| NDArray | sigma | Standard deviations of the distributions. |
| Shape | shape | Shape to be sampled from each random distribution. |
| DType | dtype | DType of the output in case this can't be inferred. Defaults to float32 if not defined (dtype=None). |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
SamplePoisson(NDArray, Shape, DType)
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
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::
lam = [ 1.0, 8.5 ]
// Draw a single sample for each distribution
sample_poisson(lam) = [ 0., 13.]
// Draw a vector containing two samples for each distribution
sample_poisson(lam, shape=(2)) = [[ 0., 4.],
[ 13., 8.]]
Defined in C:\Jenkins\workspace\mxnet\mxnet\src\operator\random\multisample_op.cc:L286
Declaration
public static NDArray SamplePoisson(NDArray lam, Shape shape = null, DType dtype = null)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | lam | Lambda (rate) parameters of the distributions. |
| Shape | shape | Shape to be sampled from each random distribution. |
| DType | dtype | DType of the output in case this can't be inferred. Defaults to float32 if not defined (dtype=None). |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
SampleUniform(NDArray, NDArray, Shape, DType)
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
operator is not set, then one sample will be drawn per distribution and the output array
has the same shape as the input arrays.
Examples::
low = [ 0.0, 2.5 ]
high = [ 1.0, 3.7 ]
// Draw a single sample for each distribution
sample_uniform(low, high) = [ 0.40451524, 3.18687344]
// Draw a vector containing two samples for each distribution
sample_uniform(low, high, shape=(2)) = [[ 0.40451524, 0.18017688],
[ 3.18687344, 3.68352246]]
Defined in C:\Jenkins\workspace\mxnet\mxnet\src\operator\random\multisample_op.cc:L277
Declaration
public static NDArray SampleUniform(NDArray low, NDArray high, Shape shape = null, DType dtype = null)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | low | Lower bounds of the distributions. |
| NDArray | high | Upper bounds of the distributions. |
| Shape | shape | Shape to be sampled from each random distribution. |
| DType | dtype | DType of the output in case this can't be inferred. Defaults to float32 if not defined (dtype=None). |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
SampleUniqueZipfian(Int32, Shape)
Draw random samples from an an approximately log-uniform
or Zipfian distribution without replacement.
This operation takes a 2-D shape `(batch_size, num_sampled)`,
and randomly generates *num_sampled* samples from the range of integers [0, range_max)
for each instance in the batch.
The elements in each instance are drawn without replacement from the base distribution.
The base distribution for this operator is an approximately log-uniform or Zipfian distribution:
P(class) = (log(class + 2) - log(class + 1)) / log(range_max + 1)
Additionaly, it also returns the number of trials used to obtain `num_sampled` samples for
each instance in the batch.
Example::
samples, trials = _sample_unique_zipfian(750000, shape=(4, 8192))
unique(samples[0]) = 8192
unique(samples[3]) = 8192
trials[0] = 16435
Defined in C:\Jenkins\workspace\mxnet\mxnet\src\operator\random\unique_sample_op.cc:L66
Declaration
public static NDArray SampleUniqueZipfian(int range_max, Shape shape = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | range_max | The number of possible classes. |
| Shape | shape | 2-D shape of the output, where shape[0] is the batch size, and shape[1] is the number of candidates to sample for each batch. |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
ScatterElemwiseDiv(NDArray, NDArray)
Divides arguments element-wise. If the left-hand-side input is 'row_sparse', then
only the values which exist in the left-hand sparse array are computed. The 'missing' values
are ignored.
The storage type of ``_scatter_elemwise_div`` output depends on storage types of inputs
- _scatter_elemwise_div(row_sparse, row_sparse) = row_sparse
- _scatter_elemwise_div(row_sparse, dense) = row_sparse
- _scatter_elemwise_div(row_sparse, csr) = row_sparse
- otherwise, ``_scatter_elemwise_div`` behaves exactly like elemwise_div and generates output
with default storage
Declaration
public static NDArray ScatterElemwiseDiv(NDArray lhs, NDArray rhs)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | lhs | first input |
| NDArray | rhs | second input |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
ScatterMinusScalar(NDArray, Single)
Subtracts a scalar to a tensor element-wise. If the left-hand-side input is
'row_sparse' or 'csr', then only the values which exist in the left-hand sparse array are computed.
The 'missing' values are ignored.
The storage type of ``_scatter_minus_scalar`` output depends on storage types of inputs
- _scatter_minus_scalar(row_sparse, scalar) = row_sparse
- _scatter_minus_scalar(csr, scalar) = csr
- otherwise, ``_scatter_minus_scalar`` behaves exactly like _minus_scalar and generates output
with default storage
Declaration
public static NDArray ScatterMinusScalar(NDArray data, float scalar)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | source input |
| System.Single | scalar | scalar input |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
ScatterNd(NDArray, NDArray, Shape)
Declaration
public static NDArray ScatterNd(NDArray data, NDArray indices, Shape shape)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | |
| NDArray | indices | |
| Shape | shape |
Returns
| Type | Description |
|---|---|
| NDArray |
ScatterPlusScalar(NDArray, Single)
Adds a scalar to a tensor element-wise. If the left-hand-side input is
'row_sparse' or 'csr', then only the values which exist in the left-hand sparse array are computed.
The 'missing' values are ignored.
The storage type of ``_scatter_plus_scalar`` output depends on storage types of inputs
- _scatter_plus_scalar(row_sparse, scalar) = row_sparse
- _scatter_plus_scalar(csr, scalar) = csr
- otherwise, ``_scatter_plus_scalar`` behaves exactly like _plus_scalar and generates output
with default storage
Declaration
public static NDArray ScatterPlusScalar(NDArray data, float scalar)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | source input |
| System.Single | scalar | scalar input |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
ScatterSetNd(NDArray, NDArray, NDArray, Shape)
This operator has the same functionality as scatter_nd
except that it does not reset the elements not indexed by the input
index `NDArray` in the input data `NDArray`. output should be explicitly
given and be the same as lhs.
.. note:: This operator is for internal use only.
Examples::
data = [2, 3, 0]
indices = [[1, 1, 0], [0, 1, 0]]
out = [[1, 1], [1, 1]]
_scatter_set_nd(lhs=out, rhs=data, indices=indices, out=out)
out = [[0, 1], [2, 3]]
Declaration
public static NDArray ScatterSetNd(NDArray lhs, NDArray rhs, NDArray indices, Shape shape)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | lhs | source input |
| NDArray | rhs | value to assign |
| NDArray | indices | indices |
| Shape | shape | Shape of output. |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
SequenceLast(NDArray, NDArray, Boolean, Int32)
Takes the last element of a sequence.
This function takes an n-dimensional input array of the form
[max_sequence_length, batch_size, other_feature_dims] and returns a (n-1)-dimensional array
of the form [batch_size, other_feature_dims].
Parameter `sequence_length` is used to handle variable-length sequences. `sequence_length` should be
an input array of positive ints of dimension [batch_size]. To use this parameter,
set `use_sequence_length` to `True`, otherwise each example in the batch is assumed
to have the max sequence length.
.. note:: Alternatively, you can also use `take` operator.
Example::
x = [[[ 1., 2., 3.],
[ 4., 5., 6.],
[ 7., 8., 9.]],
[[ 10., 11., 12.],
[ 13., 14., 15.],
[ 16., 17., 18.]],
[[ 19., 20., 21.],
[ 22., 23., 24.],
[ 25., 26., 27.]]]
// returns last sequence when sequence_length parameter is not used
SequenceLast(x) = [[ 19., 20., 21.],
[ 22., 23., 24.],
[ 25., 26., 27.]]
// sequence_length is used
SequenceLast(x, sequence_length=[1,1,1], use_sequence_length=True) =
[[ 1., 2., 3.],
[ 4., 5., 6.],
[ 7., 8., 9.]]
// sequence_length is used
SequenceLast(x, sequence_length=[1,2,3], use_sequence_length=True) =
[[ 1., 2., 3.],
[ 13., 14., 15.],
[ 25., 26., 27.]]
Defined in C:\Jenkins\workspace\mxnet\mxnet\src\operator\sequence_last.cc:L100
Declaration
public static NDArray SequenceLast(NDArray data, NDArray sequence_length, bool use_sequence_length = false, int axis = 0)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | n-dimensional input array of the form [max_sequence_length, batch_size, other_feature_dims] where n>2 |
| NDArray | sequence_length | vector of sequence lengths of the form [batch_size] |
| System.Boolean | use_sequence_length | If set to true, this layer takes in an extra input parameter |
| System.Int32 | axis | The sequence axis. Only values of 0 and 1 are currently supported. |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
SequenceMask(NDArray, NDArray, Boolean, Single, Int32)
Sets all elements outside the sequence to a constant value.
This function takes an n-dimensional input array of the form
[max_sequence_length, batch_size, other_feature_dims] and returns an array of the same shape.
Parameter `sequence_length` is used to handle variable-length sequences. `sequence_length`
should be an input array of positive ints of dimension [batch_size].
To use this parameter, set `use_sequence_length` to `True`,
otherwise each example in the batch is assumed to have the max sequence length and
this operator works as the `identity` operator.
Example::
x = [[[ 1., 2., 3.],
[ 4., 5., 6.]],
[[ 7., 8., 9.],
[ 10., 11., 12.]],
[[ 13., 14., 15.],
[ 16., 17., 18.]]]
// Batch 1
B1 = [[ 1., 2., 3.],
[ 7., 8., 9.],
[ 13., 14., 15.]]
// Batch 2
B2 = [[ 4., 5., 6.],
[ 10., 11., 12.],
[ 16., 17., 18.]]
// works as identity operator when sequence_length parameter is not used
SequenceMask(x) = [[[ 1., 2., 3.],
[ 4., 5., 6.]],
[[ 7., 8., 9.],
[ 10., 11., 12.]],
[[ 13., 14., 15.],
[ 16., 17., 18.]]]
// sequence_length [1,1] means 1 of each batch will be kept
// and other rows are masked with default mask value = 0
SequenceMask(x, sequence_length=[1,1], use_sequence_length=True) =
[[[ 1., 2., 3.],
[ 4., 5., 6.]],
[[ 0., 0., 0.],
[ 0., 0., 0.]],
[[ 0., 0., 0.],
[ 0., 0., 0.]]]
// sequence_length [2,3] means 2 of batch B1 and 3 of batch B2 will be kept
// and other rows are masked with value = 1
SequenceMask(x, sequence_length=[2,3], use_sequence_length=True, value=1) =
[[[ 1., 2., 3.],
[ 4., 5., 6.]],
[[ 7., 8., 9.],
[ 10., 11., 12.]],
[[ 1., 1., 1.],
[ 16., 17., 18.]]]
Defined in C:\Jenkins\workspace\mxnet\mxnet\src\operator\sequence_mask.cc:L186
Declaration
public static NDArray SequenceMask(NDArray data, NDArray sequence_length, bool use_sequence_length = false, float value = 0F, int axis = 0)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | n-dimensional input array of the form [max_sequence_length, batch_size, other_feature_dims] where n>2 |
| NDArray | sequence_length | vector of sequence lengths of the form [batch_size] |
| System.Boolean | use_sequence_length | If set to true, this layer takes in an extra input parameter |
| System.Single | value | The value to be used as a mask. |
| System.Int32 | axis | The sequence axis. Only values of 0 and 1 are currently supported. |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
SequenceReverse(NDArray, NDArray, Boolean, Int32)
Reverses the elements of each sequence.
This function takes an n-dimensional input array of the form [max_sequence_length, batch_size, other_feature_dims]
and returns an array of the same shape.
Parameter `sequence_length` is used to handle variable-length sequences.
`sequence_length` should be an input array of positive ints of dimension [batch_size].
To use this parameter, set `use_sequence_length` to `True`,
otherwise each example in the batch is assumed to have the max sequence length.
Example::
x = [[[ 1., 2., 3.],
[ 4., 5., 6.]],
[[ 7., 8., 9.],
[ 10., 11., 12.]],
[[ 13., 14., 15.],
[ 16., 17., 18.]]]
// Batch 1
B1 = [[ 1., 2., 3.],
[ 7., 8., 9.],
[ 13., 14., 15.]]
// Batch 2
B2 = [[ 4., 5., 6.],
[ 10., 11., 12.],
[ 16., 17., 18.]]
// returns reverse sequence when sequence_length parameter is not used
SequenceReverse(x) = [[[ 13., 14., 15.],
[ 16., 17., 18.]],
[[ 7., 8., 9.],
[ 10., 11., 12.]],
[[ 1., 2., 3.],
[ 4., 5., 6.]]]
// sequence_length [2,2] means 2 rows of
// both batch B1 and B2 will be reversed.
SequenceReverse(x, sequence_length=[2,2], use_sequence_length=True) =
[[[ 7., 8., 9.],
[ 10., 11., 12.]],
[[ 1., 2., 3.],
[ 4., 5., 6.]],
[[ 13., 14., 15.],
[ 16., 17., 18.]]]
// sequence_length [2,3] means 2 of batch B2 and 3 of batch B3
// will be reversed.
SequenceReverse(x, sequence_length=[2,3], use_sequence_length=True) =
[[[ 7., 8., 9.],
[ 16., 17., 18.]],
[[ 1., 2., 3.],
[ 10., 11., 12.]],
[[ 13., 14, 15.],
[ 4., 5., 6.]]]
Defined in C:\Jenkins\workspace\mxnet\mxnet\src\operator\sequence_reverse.cc:L122
Declaration
public static NDArray SequenceReverse(NDArray data, NDArray sequence_length, bool use_sequence_length = false, int axis = 0)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | n-dimensional input array of the form [max_sequence_length, batch_size, other dims] where n>2 |
| NDArray | sequence_length | vector of sequence lengths of the form [batch_size] |
| System.Boolean | use_sequence_length | If set to true, this layer takes in an extra input parameter |
| System.Int32 | axis | The sequence axis. Only 0 is currently supported. |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
SgdMomUpdate(NDArray, NDArray, NDArray, Single, Single, Single, Single, Single, Boolean)
Declaration
public static NDArray SgdMomUpdate(NDArray weight, NDArray grad, NDArray mom, float lr, float momentum = 0F, float wd = 0F, float rescale_grad = 1F, float clip_gradient = -1F, bool lazy_update = true)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | weight | |
| NDArray | grad | |
| NDArray | mom | |
| System.Single | lr | |
| System.Single | momentum | |
| System.Single | wd | |
| System.Single | rescale_grad | |
| System.Single | clip_gradient | |
| System.Boolean | lazy_update |
Returns
| Type | Description |
|---|---|
| NDArray |
SgdUpdate(NDArray, NDArray, Single, Single, Single, Single, Boolean)
Declaration
public static NDArray SgdUpdate(NDArray weight, NDArray grad, float lr, float wd = 0F, float rescale_grad = 1F, float clip_gradient = -1F, bool lazy_update = true)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | weight | |
| NDArray | grad | |
| System.Single | lr | |
| System.Single | wd | |
| System.Single | rescale_grad | |
| System.Single | clip_gradient | |
| System.Boolean | lazy_update |
Returns
| Type | Description |
|---|---|
| NDArray |
ShapeArray(NDArray, Nullable<Int32>, Nullable<Int32>, Nullable<Int32>, Nullable<Int32>)
Returns a 1D int64 array containing the shape of data.
Example::
shape_array([[1,2,3,4], [5,6,7,8]]) = [2,4]
Defined in C:\Jenkins\workspace\mxnet\mxnet\src\operator\tensor\elemwise_unary_op_basic.cc:L529
Declaration
public static NDArray ShapeArray(NDArray data, int? lhs_begin = default(int? ), int? lhs_end = default(int? ), int? rhs_begin = default(int? ), int? rhs_end = default(int? ))
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | Input Array. |
| System.Nullable<System.Int32> | lhs_begin | Defaults to 0. The beginning index along which the lhs dimensions are to be reshaped. Supports negative indices. |
| System.Nullable<System.Int32> | lhs_end | Defaults to None. The ending index along which the lhs dimensions are to be used for reshaping. Supports negative indices. |
| System.Nullable<System.Int32> | rhs_begin | Defaults to 0. The beginning index along which the rhs dimensions are to be used for reshaping. Supports negative indices. |
| System.Nullable<System.Int32> | rhs_end | Defaults to None. The ending index along which the rhs dimensions are to be used for reshaping. Supports negative indices. |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
Shuffle(NDArray)
Randomly shuffle the elements.
This shuffles the array along the first axis.
The order of the elements in each subarray does not change.
For example, if a 2D array is given, the order of the rows randomly changes,
but the order of the elements in each row does not change.
Declaration
public static NDArray Shuffle(NDArray data)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | Data to be shuffled. |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
Sigmoid(NDArray)
Computes sigmoid of x element-wise.
.. math::
y = 1 / (1 + exp(-x))
The storage type of ``sigmoid`` output is always dense
Defined in C:\Jenkins\workspace\mxnet\mxnet\src\operator\tensor\elemwise_unary_op_basic.cc:L101
Declaration
public static NDArray Sigmoid(NDArray data)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | The input array. |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
Sign(NDArray)
Returns element-wise sign of the input.
Example::
sign([-2, 0, 3]) = [-1, 0, 1]
The storage type of ``sign`` output depends upon the input storage type:
- sign(default) = default
- sign(row_sparse) = row_sparse
- sign(csr) = csr
Defined in C:\Jenkins\workspace\mxnet\mxnet\src\operator\tensor\elemwise_unary_op_basic.cc:L704
Declaration
public static NDArray Sign(NDArray data)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | The input array. |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
SignsgdUpdate(NDArray, NDArray, Single, Single, Single, Single)
Declaration
public static NDArray SignsgdUpdate(NDArray weight, NDArray grad, float lr, float wd = 0F, float rescale_grad = 1F, float clip_gradient = -1F)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | weight | |
| NDArray | grad | |
| System.Single | lr | |
| System.Single | wd | |
| System.Single | rescale_grad | |
| System.Single | clip_gradient |
Returns
| Type | Description |
|---|---|
| NDArray |
SignumUpdate(NDArray, NDArray, NDArray, Single, Single, Single, Single, Single, Single)
Declaration
public static NDArray SignumUpdate(NDArray weight, NDArray grad, NDArray mom, float lr, float momentum = 0F, float wd = 0F, float rescale_grad = 1F, float clip_gradient = -1F, float wd_lh = 0F)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | weight | |
| NDArray | grad | |
| NDArray | mom | |
| System.Single | lr | |
| System.Single | momentum | |
| System.Single | wd | |
| System.Single | rescale_grad | |
| System.Single | clip_gradient | |
| System.Single | wd_lh |
Returns
| Type | Description |
|---|---|
| NDArray |
Sin(NDArray)
Computes the element-wise sine of the input array.
The input should be in radians (:math:`2\pi` rad equals 360 degrees).
.. math::
sin([0, \pi/4, \pi/2]) = [0, 0.707, 1]
The storage type of ``sin`` output depends upon the input storage type:
- sin(default) = default
- sin(row_sparse) = row_sparse
- sin(csr) = csr
Defined in C:\Jenkins\workspace\mxnet\mxnet\src\operator\tensor\elemwise_unary_op_trig.cc:L46
Declaration
public static NDArray Sin(NDArray data)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | The input array. |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
Sinh(NDArray)
Returns the hyperbolic sine of the input array, computed element-wise.
.. math::
sinh(x) = 0.5\times(exp(x) - exp(-x))
The storage type of ``sinh`` output depends upon the input storage type:
- sinh(default) = default
- sinh(row_sparse) = row_sparse
- sinh(csr) = csr
Defined in C:\Jenkins\workspace\mxnet\mxnet\src\operator\tensor\elemwise_unary_op_trig.cc:L201
Declaration
public static NDArray Sinh(NDArray data)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | The input array. |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
SizeArray(NDArray)
Returns a 1D int64 array containing the size of data.
Example::
size_array([[1,2,3,4], [5,6,7,8]]) = [8]
Defined in C:\Jenkins\workspace\mxnet\mxnet\src\operator\tensor\elemwise_unary_op_basic.cc:L581
Declaration
public static NDArray SizeArray(NDArray data)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | Input Array. |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
Slice(NDArray, Shape, Shape, Shape)
Declaration
public static NDArray Slice(NDArray data, Shape begin, Shape end, Shape step = null)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | |
| Shape | begin | |
| Shape | end | |
| Shape | step |
Returns
| Type | Description |
|---|---|
| NDArray |
SliceAssign(NDArray, NDArray, Shape, Shape, Shape)
Assign the rhs to a cropped subset of lhs.
Requirements
------------
- output should be explicitly given and be the same as lhs.
- lhs and rhs are of the same data type, and on the same device.
From:C:\Jenkins\workspace\mxnet\mxnet\src\operator\tensor\matrix_op.cc:559
Declaration
public static NDArray SliceAssign(NDArray lhs, NDArray rhs, Shape begin, Shape end, Shape step = null)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | lhs | Source input |
| NDArray | rhs | value to assign |
| Shape | begin | starting indices for the slice operation, supports negative indices. |
| Shape | end | ending indices for the slice operation, supports negative indices. |
| Shape | step | step for the slice operation, supports negative values. |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
SliceAssignScalar(NDArray, Shape, Shape, Double, Shape)
(Assign the scalar to a cropped subset of the input.
Requirements
------------
- output should be explicitly given and be the same as input
)
From:C:\Jenkins\workspace\mxnet\mxnet\src\operator\tensor\matrix_op.cc:584
Declaration
public static NDArray SliceAssignScalar(NDArray data, Shape begin, Shape end, double scalar = 0, Shape step = null)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | Source input |
| Shape | begin | starting indices for the slice operation, supports negative indices. |
| Shape | end | ending indices for the slice operation, supports negative indices. |
| System.Double | scalar | The scalar value for assignment. |
| Shape | step | step for the slice operation, supports negative values. |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
SliceAxis(NDArray, Int32, Int32, Nullable<Int32>)
Slices along a given axis.
Returns an array slice along a given `axis` starting from the `begin` index
to the `end` index.
Examples::
x = [[ 1., 2., 3., 4.],
[ 5., 6., 7., 8.],
[ 9., 10., 11., 12.]]
slice_axis(x, axis=0, begin=1, end=3) = [[ 5., 6., 7., 8.],
[ 9., 10., 11., 12.]]
slice_axis(x, axis=1, begin=0, end=2) = [[ 1., 2.],
[ 5., 6.],
[ 9., 10.]]
slice_axis(x, axis=1, begin=-3, end=-1) = [[ 2., 3.],
[ 6., 7.],
[ 10., 11.]]
Defined in C:\Jenkins\workspace\mxnet\mxnet\src\operator\tensor\matrix_op.cc:L620
Declaration
public static NDArray SliceAxis(NDArray data, int axis, int begin, int? end)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | Source input |
| System.Int32 | axis | Axis along which to be sliced, supports negative indexes. |
| System.Int32 | begin | The beginning index along the axis to be sliced, supports negative indexes. |
| System.Nullable<System.Int32> | end | The ending index along the axis to be sliced, supports negative indexes. |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
SliceChannel(NDArray, Int32, Int32, Boolean)
Splits an array along a particular axis into multiple sub-arrays.
.. note:: ``SliceChannel`` is deprecated. Use ``split`` instead.
**Note** that `num_outputs` should evenly divide the length of the axis
along which to split the array.
Example::
x = [[[ 1.]
[ 2.]]
[[ 3.]
[ 4.]]
[[ 5.]
[ 6.]]]
x.shape = (3, 2, 1)
y = split(x, axis=1, num_outputs=2) // a list of 2 arrays with shape (3, 1, 1)
y = [[[ 1.]]
[[ 3.]]
[[ 5.]]]
[[[ 2.]]
[[ 4.]]
[[ 6.]]]
y[0].shape = (3, 1, 1)
z = split(x, axis=0, num_outputs=3) // a list of 3 arrays with shape (1, 2, 1)
z = [[[ 1.]
[ 2.]]]
[[[ 3.]
[ 4.]]]
[[[ 5.]
[ 6.]]]
z[0].shape = (1, 2, 1)
`squeeze_axis=1` removes the axis with length 1 from the shapes of the output arrays.
**Note** that setting `squeeze_axis` to ``1`` removes axis with length 1 only
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.]]
[[ 3.]
[ 4.]]
[[ 5.]
[ 6.]]
z[0].shape = (2 ,1 )
Defined in C:\Jenkins\workspace\mxnet\mxnet\src\operator\slice_channel.cc:L107
Declaration
public static NDArray SliceChannel(NDArray data, int num_outputs, int axis = 1, bool squeeze_axis = false)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | The input |
| System.Int32 | num_outputs | Number of splits. Note that this should evenly divide the length of the |
| System.Int32 | axis | Axis along which to split. |
| System.Boolean | squeeze_axis | If true, Removes the axis with length 1 from the shapes of the output arrays. Note that
setting |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
SliceLike(NDArray, NDArray, Shape)
Slices a region of the array like the shape of another array.
This function is similar to ``slice``, however, the `begin` are always `0`s
and `end` of specific axes are inferred from the second input `shape_like`.
Given the second `shape_like` input of ``shape=(d_0, d_1, ..., d_n-1)``,
a ``slice_like`` operator with default empty `axes`, it performs the
following operation:
`` out = slice(input, begin=(0, 0, ..., 0), end=(d_0, d_1, ..., d_n-1))``.
When `axes` is not empty, it is used to speficy which axes are being sliced.
Given a 4-d input data, ``slice_like`` operator with ``axes=(0, 2, -1)``
will perform the following operation:
`` out = slice(input, begin=(0, 0, 0, 0), end=(d_0, None, d_2, d_3))``.
Note that it is allowed to have first and second input with different dimensions,
however, you have to make sure the `axes` are specified and not exceeding the
dimension limits.
For example, given `input_1` with ``shape=(2,3,4,5)`` and `input_2` with
``shape=(1,2,3)``, it is not allowed to use:
`` out = slice_like(a, b)`` because ndim of `input_1` is 4, and ndim of `input_2`
is 3.
The following is allowed in this situation:
`` out = slice_like(a, b, axes=(0, 2))``
Example::
x = [[ 1., 2., 3., 4.],
[ 5., 6., 7., 8.],
[ 9., 10., 11., 12.]]
y = [[ 0., 0., 0.],
[ 0., 0., 0.]]
slice_like(x, y) = [[ 1., 2., 3.]
[ 5., 6., 7.]]
slice_like(x, y, axes=(0, 1)) = [[ 1., 2., 3.]
[ 5., 6., 7.]]
slice_like(x, y, axes=(0)) = [[ 1., 2., 3., 4.]
[ 5., 6., 7., 8.]]
slice_like(x, y, axes=(-1)) = [[ 1., 2., 3.]
[ 5., 6., 7.]
[ 9., 10., 11.]]
Defined in C:\Jenkins\workspace\mxnet\mxnet\src\operator\tensor\matrix_op.cc:L689
Declaration
public static NDArray SliceLike(NDArray data, NDArray shape_like, Shape axes = null)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | Source input |
| NDArray | shape_like | Shape like input |
| Shape | axes | List of axes on which input data will be sliced according to the corresponding size of the second input. By default will slice on all axes. Negative axes are supported. |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
SmoothL1(NDArray, Single)
Declaration
public static NDArray SmoothL1(NDArray data, float scalar)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | |
| System.Single | scalar |
Returns
| Type | Description |
|---|---|
| NDArray |
Softmax(NDArray, Int32, Nullable<Double>, DType)
Applies the softmax function.
The resulting array contains elements in the range (0,1) and the elements along the given axis sum up to 1.
.. math::
softmax(\mathbf{z/t})_j = \frac{e^{z_j/t}}{\sum_{k=1}^K e^{z_k/t}}
for :math:`j = 1, ..., K`
t is the temperature parameter in softmax function. By default, t equals 1.0
Example::
x = [[ 1. 1. 1.]
[ 1. 1. 1.]]
softmax(x,axis=0) = [[ 0.5 0.5 0.5]
[ 0.5 0.5 0.5]]
softmax(x,axis=1) = [[ 0.33333334, 0.33333334, 0.33333334],
[ 0.33333334, 0.33333334, 0.33333334]]
Defined in C:\Jenkins\workspace\mxnet\mxnet\src\operator\nn\softmax.cc:L93
Declaration
public static NDArray Softmax(NDArray data, int axis = -1, double? temperature = default(double? ), DType dtype = null)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | The input array. |
| System.Int32 | axis | The axis along which to compute softmax. |
| System.Nullable<System.Double> | temperature | Temperature parameter in softmax |
| DType | dtype | DType of the output in case this can't be inferred. Defaults to the same as input's dtype if not defined (dtype=None). |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
SoftmaxActivation(NDArray, SoftmaxMode)
Applies softmax activation to input. This is intended for internal layers.
.. note::
This operator has been deprecated, please use `softmax`.
If `mode` = ``instance``, this operator will compute a softmax for each instance in the batch.
This is the default mode.
If `mode` = ``channel``, this operator will compute a k-class softmax at each position
of each instance, where `k` = ``num_channel``. This mode can only be used when the input array
has at least 3 dimensions.
This can be used for `fully convolutional network`, `image segmentation`, etc.
Example::
>>> input_array = mx.nd.array([[3., 0.5, -0.5, 2., 7.],
>>> [2., -.4, 7., 3., 0.2]])
>>> softmax_act = mx.nd.SoftmaxActivation(input_array)
>>> print softmax_act.asnumpy()
[[ 1.78322066e-02 1.46375655e-03 5.38485940e-04 6.56010211e-03 9.73605454e-01]
[ 6.56221947e-03 5.95310994e-04 9.73919690e-01 1.78379621e-02 1.08472735e-03]]
Defined in C:\Jenkins\workspace\mxnet\mxnet\src\operator\nn\softmax_activation.cc:L59
Declaration
public static NDArray SoftmaxActivation(NDArray data, SoftmaxMode mode = SoftmaxMode.Instance)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | The input array. |
| SoftmaxMode | mode | Specifies how to compute the softmax. If set to |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
SoftmaxCrossEntropy(NDArray, NDArray)
Calculate cross entropy of softmax output and one-hot label.
- This operator computes the cross entropy in two steps:
- Applies softmax function on the input array.
- Computes and returns the cross entropy loss between the softmax output and the labels.
- The softmax function and cross entropy loss is given by:
- Softmax Function:
.. math:: \text{softmax}(x)_i = \frac{exp(x_i)}{\sum_j exp(x_j)}
- Cross Entropy Function:
.. math:: \text{CE(label, output)} = - \sum_i \text{label}_i \log(\text{output}_i)
Example::
x = [[1, 2, 3],
[11, 7, 5]]
label = [2, 0]
softmax(x) = [[0.09003057, 0.24472848, 0.66524094],
[0.97962922, 0.01794253, 0.00242826]]
softmax_cross_entropy(data, label) = - log(0.66524084) - log(0.97962922) = 0.4281871
Defined in C:\Jenkins\workspace\mxnet\mxnet\src\operator\loss_binary_op.cc:L59
Declaration
public static NDArray SoftmaxCrossEntropy(NDArray data, NDArray label)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | Input data |
| NDArray | label | Input label |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
SoftmaxOutput(NDArray, NDArray, Single, Single, Boolean, Boolean, Boolean, SoftmaxoutputNormalization, Boolean, Single)
Computes the gradient of cross entropy loss with respect to softmax output.
- This operator computes the gradient in two steps.
The cross entropy loss does not actually need to be computed.
- Applies softmax function on the input array.
- Computes and returns the gradient of cross entropy loss w.r.t. the softmax output.
- The softmax function, cross entropy loss and gradient is given by:
- Softmax Function:
.. math:: \text{softmax}(x)_i = \frac{exp(x_i)}{\sum_j exp(x_j)}
- Cross Entropy Function:
.. math:: \text{CE(label, output)} = - \sum_i \text{label}_i \log(\text{output}_i)
- The gradient of cross entropy loss w.r.t softmax output:
.. math:: \text{gradient} = \text{output} - \text{label}
- During forward propagation, the softmax function is computed for each instance in the input array.
For general *N*-D input arrays with shape :math:`(d_1, d_2, ..., d_n)`. The size is
:math:`s=d_1 \cdot d_2 \cdot \cdot \cdot d_n`. We can use the parameters `preserve_shape`
and `multi_output` to specify the way to compute softmax:
- By default, `preserve_shape` is ``false``. This operator will reshape the input array
into a 2-D array with shape :math:`(d_1, \frac{s}{d_1})` and then compute the softmax function for
each row in the reshaped array, and afterwards reshape it back to the original shape
:math:`(d_1, d_2, ..., d_n)`.
- If `preserve_shape` is ``true``, the softmax function will be computed along
the last axis (`axis` = ``-1``).
- If `multi_output` is ``true``, the softmax function will be computed along
the second axis (`axis` = ``1``).
- During backward propagation, the gradient of cross-entropy loss w.r.t softmax output array is computed.
The provided label can be a one-hot label array or a probability label array.
- 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`**.
Example::
data = [[1,2,3,4],[2,2,2,2],[3,3,3,3],[4,4,4,4]]
label = [1,0,2,3]
ignore_label = 1
SoftmaxOutput(data=data, label = label,\
multi_output=true, use_ignore=true,\
ignore_label=ignore_label)
## forward softmax output
[[ 0.0320586 0.08714432 0.23688284 0.64391428]
[ 0.25 0.25 0.25 0.25 ]
[ 0.25 0.25 0.25 0.25 ]
[ 0.25 0.25 0.25 0.25 ]]
## backward gradient output
[[ 0. 0. 0. 0. ]
[-0.75 0.25 0.25 0.25]
[ 0.25 0.25 -0.75 0.25]
[ 0.25 0.25 0.25 -0.75]]
## notice that the first row is all 0 because label[0] is 1, which is equal to ignore_label.
- The parameter `grad_scale` can be used to rescale the gradient, which is often used to
give each loss function different weights.
- This operator also supports various ways to normalize the gradient by `normalization`,
The `normalization` is applied if softmax output has different shape than the labels.
The `normalization` mode can be set to the followings:
- ``'null'``: do nothing.
- ``'batch'``: divide the gradient by the batch size.
- ``'valid'``: divide the gradient by the number of instances which are not ignored.
Defined in C:\Jenkins\workspace\mxnet\mxnet\src\operator\softmax_output.cc:L230
Declaration
public static NDArray SoftmaxOutput(NDArray data, NDArray label, float grad_scale = 1F, float ignore_label = -1F, bool multi_output = false, bool use_ignore = false, bool preserve_shape = false, SoftmaxoutputNormalization normalization = SoftmaxoutputNormalization.Null, bool out_grad = false, float smooth_alpha = 0F)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | Input array. |
| NDArray | label | Ground truth label. |
| System.Single | grad_scale | Scales the gradient by a float factor. |
| System.Single | ignore_label | The instances whose |
| System.Boolean | multi_output | If set to |
| System.Boolean | use_ignore | If set to |
| System.Boolean | preserve_shape | If set to |
| SoftmaxoutputNormalization | normalization | Normalizes the gradient. |
| System.Boolean | out_grad | Multiplies gradient with output gradient element-wise. |
| System.Single | smooth_alpha | Constant for computing a label smoothed version of cross-entropyfor the backwards pass. This constant gets subtracted from theone-hot encoding of the gold label and distributed uniformly toall other labels. |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
Softmin(NDArray, Int32, Nullable<Double>, DType)
Applies the softmin function.
The resulting array contains elements in the range (0,1) and the elements along the given axis sum
up to 1.
.. math::
softmin(\mathbf{z/t})_j = \frac{e^{-z_j/t}}{\sum_{k=1}^K e^{-z_k/t}}
for :math:`j = 1, ..., K`
t is the temperature parameter in softmax function. By default, t equals 1.0
Example::
x = [[ 1. 2. 3.]
[ 3. 2. 1.]]
softmin(x,axis=0) = [[ 0.88079703, 0.5, 0.11920292],
[ 0.11920292, 0.5, 0.88079703]]
softmin(x,axis=1) = [[ 0.66524094, 0.24472848, 0.09003057],
[ 0.09003057, 0.24472848, 0.66524094]]
Defined in C:\Jenkins\workspace\mxnet\mxnet\src\operator\nn\softmax.cc:L153
Declaration
public static NDArray Softmin(NDArray data, int axis = -1, double? temperature = default(double? ), DType dtype = null)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | The input array. |
| System.Int32 | axis | The axis along which to compute softmax. |
| System.Nullable<System.Double> | temperature | Temperature parameter in softmax |
| DType | dtype | DType of the output in case this can't be inferred. Defaults to the same as input's dtype if not defined (dtype=None). |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
Softsign(NDArray)
Computes softsign of x element-wise.
.. math::
y = x / (1 + abs(x))
The storage type of ``softsign`` output is always dense
Defined in C:\Jenkins\workspace\mxnet\mxnet\src\operator\tensor\elemwise_unary_op_basic.cc:L145
Declaration
public static NDArray Softsign(NDArray data)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | The input array. |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
Sort(NDArray, Nullable<Int32>, Boolean)
Returns a sorted copy of an input array along the given axis.
Examples::
x = [[ 1, 4],
[ 3, 1]]
// sorts along the last axis
sort(x) = [[ 1., 4.],
[ 1., 3.]]
// flattens and then sorts
sort(x) = [ 1., 1., 3., 4.]
// sorts along the first axis
sort(x, axis=0) = [[ 1., 1.],
[ 3., 4.]]
// in a descend order
sort(x, is_ascend=0) = [[ 4., 1.],
[ 3., 1.]]
Defined in C:\Jenkins\workspace\mxnet\mxnet\src\operator\tensor\ordering_op.cc:L127
Declaration
public static NDArray Sort(NDArray data, int? axis, bool is_ascend = true)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | The input array |
| System.Nullable<System.Int32> | axis | Axis along which to choose sort the input tensor. If not given, the flattened array is used. Default is -1. |
| System.Boolean | is_ascend | Whether to sort in ascending or descending order. |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
SpaceToDepth(NDArray, Int32)
Rearranges(permutes) blocks of spatial data into depth.
Similar to ONNX SpaceToDepth operator:
https://github.com/onnx/onnx/blob/master/docs/Operators.md#SpaceToDepth
The output is a new tensor where the values from height and width dimension are
moved to the depth dimension. The reverse of this operation is ``depth_to_space``.
.. math::
\begin{gather*}
x \prime = reshape(x, [N, C, H / block\_size, block\_size, W / block\_size, block\_size]) \\
x \prime \prime = transpose(x \prime, [0, 3, 5, 1, 2, 4]) \\
y = reshape(x \prime \prime, [N, C * (block\_size ^ 2), H / block\_size, W / block\_size])
\end{gather*}
where :math:`x` is an input tensor with default layout as :math:`[N, C, H, W]`: [batch, channels, height, width]
and :math:`y` is the output tensor of layout :math:`[N, C * (block\_size ^ 2), H / block\_size, W / block\_size]`
Example::
x = [[[[0, 6, 1, 7, 2, 8],
[12, 18, 13, 19, 14, 20],
[3, 9, 4, 10, 5, 11],
[15, 21, 16, 22, 17, 23]]]]
space_to_depth(x, 2) = [[[[0, 1, 2],
[3, 4, 5]],
[[6, 7, 8],
[9, 10, 11]],
[[12, 13, 14],
[15, 16, 17]],
[[18, 19, 20],
[21, 22, 23]]]]
Defined in C:\Jenkins\workspace\mxnet\mxnet\src\operator\tensor\matrix_op.cc:L1128
Declaration
public static NDArray SpaceToDepth(NDArray data, int block_size)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | Input ndarray |
| System.Int32 | block_size | Blocks of [block_size. block_size] are moved |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
SparseAdagradUpdate(NDArray, NDArray, NDArray, Single, Single, Single, Single, Single)
Declaration
public static NDArray SparseAdagradUpdate(NDArray weight, NDArray grad, NDArray history, float lr, float epsilon = 1E-07F, float wd = 0F, float rescale_grad = 1F, float clip_gradient = -1F)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | weight | |
| NDArray | grad | |
| NDArray | history | |
| System.Single | lr | |
| System.Single | epsilon | |
| System.Single | wd | |
| System.Single | rescale_grad | |
| System.Single | clip_gradient |
Returns
| Type | Description |
|---|---|
| NDArray |
SparseRetain(NDArray, NDArray)
pick rows specified by user input index array from a row sparse matrix
and save them in the output sparse matrix.
Example::
data = [[1, 2], [3, 4], [5, 6]]
indices = [0, 1, 3]
shape = (4, 2)
rsp_in = row_sparse(data, indices)
to_retain = [0, 3]
rsp_out = retain(rsp_in, to_retain)
rsp_out.values = [[1, 2], [5, 6]]
rsp_out.indices = [0, 3]
The storage type of ``retain`` output depends on storage types of inputs
- retain(row_sparse, default) = row_sparse
- otherwise, ``retain`` is not supported
Defined in C:\Jenkins\workspace\mxnet\mxnet\src\operator\tensor\sparse_retain.cc:L53
Declaration
public static NDArray SparseRetain(NDArray data, NDArray indices)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | The input array for sparse_retain operator. |
| NDArray | indices | The index array of rows ids that will be retained. |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
SpatialTransformer(NDArray, NDArray, SpatialtransformerTransformType, SpatialtransformerSamplerType, Shape, Nullable<Boolean>)
Applies a spatial transformer to input feature map.
Declaration
public static NDArray SpatialTransformer(NDArray data, NDArray loc, SpatialtransformerTransformType transform_type, SpatialtransformerSamplerType sampler_type, Shape target_shape = null, bool? cudnn_off = default(bool? ))
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | Input data to the SpatialTransformerOp. |
| NDArray | loc | localisation net, the output dim should be 6 when transform_type is affine. You shold initialize the weight and bias with identity tranform. |
| SpatialtransformerTransformType | transform_type | transformation type |
| SpatialtransformerSamplerType | sampler_type | sampling type |
| Shape | target_shape | output shape(h, w) of spatial transformer: (y, x) |
| System.Nullable<System.Boolean> | cudnn_off | whether to turn cudnn off |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
Split(NDArray, Int32, Int32, Boolean)
Declaration
public static NDArrayList Split(NDArray data, int num_outputs, int axis = 1, bool squeeze_axis = false)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | |
| System.Int32 | num_outputs | |
| System.Int32 | axis | |
| System.Boolean | squeeze_axis |
Returns
| Type | Description |
|---|---|
| NDArrayList |
SplitV2(NDArray, Shape, Int32, Boolean, Int32)
Splits an array along a particular axis into multiple sub-arrays.
Example::
x = [[[ 1.]
[ 2.]]
[[ 3.]
[ 4.]]
[[ 5.]
[ 6.]]]
x.shape = (3, 2, 1)
y = split_v2(x, axis=1, indices_or_sections=2) // a list of 2 arrays with shape (3, 1, 1)
y = [[[ 1.]]
[[ 3.]]
[[ 5.]]]
[[[ 2.]]
[[ 4.]]
[[ 6.]]]
y[0].shape = (3, 1, 1)
z = split_v2(x, axis=0, indices_or_sections=3) // a list of 3 arrays with shape (1, 2, 1)
z = [[[ 1.]
[ 2.]]]
[[[ 3.]
[ 4.]]]
[[[ 5.]
[ 6.]]]
z[0].shape = (1, 2, 1)
w = split_v2(x, axis=0, indices_or_sections=(1,)) // a list of 2 arrays with shape [(1, 2, 1), (2, 2, 1)]
w = [[[ 1.]
[ 2.]]]
[[[3.]
[4.]]
[[5.]
[6.]]]
w[0].shape = (1, 2, 1)
w[1].shape = (2, 2, 1)
`squeeze_axis=True` removes the axis with length 1 from the shapes of the output arrays.
**Note** that setting `squeeze_axis` to ``1`` removes axis with length 1 only
along the `axis` which it is split.
Also `squeeze_axis` can be set to true only if ``input.shape[axis] == indices_or_sections``.
Example::
z = split_v2(x, axis=0, indices_or_sections=3, squeeze_axis=1) // a list of 3 arrays with shape (2, 1)
z = [[ 1.]
[ 2.]]
[[ 3.]
[ 4.]]
[[ 5.]
[ 6.]]
z[0].shape = (2, 1)
Defined in C:\Jenkins\workspace\mxnet\mxnet\src\operator\tensor\matrix_op.cc:L1214
Declaration
public static NDArrayList SplitV2(NDArray data, Shape indices, int axis = 1, bool squeeze_axis = false, int sections = 0)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | The input |
| Shape | indices | Indices of splits. The elements should denote the boundaries of at which split is performed along
the |
| System.Int32 | axis | Axis along which to split. |
| System.Boolean | squeeze_axis | If true, Removes the axis with length 1 from the shapes of the output arrays. Note that
setting |
| System.Int32 | sections | Number of sections if equally splitted. Default to 0 which means split by indices. |
Returns
| Type | Description |
|---|---|
| NDArrayList | returns new NDArray |
Sqrt(NDArray)
Returns element-wise square-root value of the input.
.. math::
\textrm{sqrt}(x) = \sqrt{x}
Example::
sqrt([4, 9, 16]) = [2, 3, 4]
The storage type of ``sqrt`` output depends upon the input storage type:
- sqrt(default) = default
- sqrt(row_sparse) = row_sparse
- sqrt(csr) = csr
Defined in C:\Jenkins\workspace\mxnet\mxnet\src\operator\tensor\elemwise_unary_op_basic.cc:L863
Declaration
public static NDArray Sqrt(NDArray data)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | The input array. |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
Square(NDArray)
Returns element-wise squared value of the input.
.. math::
square(x) = x^2
Example::
square([2, 3, 4]) = [4, 9, 16]
The storage type of ``square`` output depends upon the input storage type:
- square(default) = default
- square(row_sparse) = row_sparse
- square(csr) = csr
Defined in C:\Jenkins\workspace\mxnet\mxnet\src\operator\tensor\elemwise_unary_op_basic.cc:L840
Declaration
public static NDArray Square(NDArray data)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | The input array. |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
SquareSum(NDArray, Shape, Boolean, Boolean)
Computes the square sum of array elements over a given axis
for row-sparse matrix. This is a temporary solution for fusing ops square and
sum together for row-sparse matrix to save memory for storing gradients.
It will become deprecated once the functionality of fusing operators is finished
in the future.
Example::
dns = mx.nd.array([[0, 0], [1, 2], [0, 0], [3, 4], [0, 0]])
rsp = dns.tostype('row_sparse')
sum = mx.nd._internal._square_sum(rsp, axis=1)
sum = [0, 5, 0, 25, 0]
Defined in C:\Jenkins\workspace\mxnet\mxnet\src\operator\tensor\square_sum.cc:L63
Declaration
public static NDArray SquareSum(NDArray data, Shape axis = null, bool keepdims = false, bool exclude = false)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | The input |
| Shape | axis | The axis or axes along which to perform the reduction. The default, |
| System.Boolean | keepdims | If this is set to |
| System.Boolean | exclude | Whether to perform reduction on axis that are NOT in axis instead. |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
Squeeze(NDArrayList, Shape)
Remove single-dimensional entries from the shape of an array.
Same behavior of defining the output tensor shape as numpy.squeeze for the most of cases.
See the following note for exception.
Examples::
data = [[[0], [1], [2]]]
squeeze(data) = [0, 1, 2]
squeeze(data, axis=0) = [[0], [1], [2]]
squeeze(data, axis=2) = [[0, 1, 2]]
squeeze(data, axis=(0, 2)) = [0, 1, 2]
.. Note::
The output of this operator will keep at least one dimension not removed. For example,
squeeze([[[4]]]) = [4], while in numpy.squeeze, the output will become a scalar.
Declaration
public static NDArray Squeeze(NDArrayList data, Shape axis = null)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArrayList | data | data to squeeze |
| Shape | axis | Selects a subset of the single-dimensional entries in the shape. If an axis is selected with shape entry greater than one, an error is raised. |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
Stack(NDArrayList, Int32, Int32)
Join a sequence of arrays along a new axis.
The axis parameter specifies the index of the new axis in the dimensions of the
result. For example, if axis=0 it will be the first dimension and if axis=-1 it
will be the last dimension.
Examples::
x = [1, 2]
y = [3, 4]
stack(x, y) = [[1, 2],
[3, 4]]
stack(x, y, axis=1) = [[1, 3],
[2, 4]]
Declaration
public static NDArray Stack(NDArrayList data, int num_args, int axis = 0)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArrayList | data | List of arrays to stack |
| System.Int32 | num_args | Number of inputs to be stacked. |
| System.Int32 | axis | The axis in the result array along which the input arrays are stacked. |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
StopGradient(NDArray)
Declaration
public static NDArray StopGradient(NDArray data)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data |
Returns
| Type | Description |
|---|---|
| NDArray |
Sum(NDArray, Shape, Boolean, Boolean)
Computes the sum of array elements over given axes.
.. Note::
`sum` and `sum_axis` are equivalent.
For ndarray of csr storage type summation along axis 0 and axis 1 is supported.
Setting keepdims or exclude to True will cause a fallback to dense operator.
Example::
data = [[[1, 2], [2, 3], [1, 3]],
[[1, 4], [4, 3], [5, 2]],
[[7, 1], [7, 2], [7, 3]]]
sum(data, axis=1)
[[ 4. 8.]
[ 10. 9.]
[ 21. 6.]]
sum(data, axis=[1,2])
[ 12. 19. 27.]
data = [[1, 2, 0],
[3, 0, 1],
[4, 1, 0]]
csr = cast_storage(data, 'csr')
sum(csr, axis=0)
[ 8. 3. 1.]
sum(csr, axis=1)
[ 3. 4. 5.]
Defined in C:\Jenkins\workspace\mxnet\mxnet\src\operator\tensor\broadcast_reduce_op_value.cc:L116
Declaration
public static NDArray Sum(NDArray data, Shape axis = null, bool keepdims = false, bool exclude = false)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | The input |
| Shape | axis | The axis or axes along which to perform the reduction. The default, |
| System.Boolean | keepdims | If this is set to |
| System.Boolean | exclude | Whether to perform reduction on axis that are NOT in axis instead. |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
Sum(NDArray, Int32, Boolean, Boolean)
Declaration
public static NDArray Sum(NDArray data, int axis, bool keepdims = false, bool exclude = false)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | |
| System.Int32 | axis | |
| System.Boolean | keepdims | |
| System.Boolean | exclude |
Returns
| Type | Description |
|---|---|
| NDArray |
SVMOutput(NDArray, NDArray, Single, Single, Boolean)
Computes support vector machine based transformation of the input.
This tutorial demonstrates using SVM as output layer for classification instead of softmax:
https://github.com/dmlc/mxnet/tree/master/example/svm_mnist.
Declaration
public static NDArray SVMOutput(NDArray data, NDArray label, float margin = 1F, float regularization_coefficient = 1F, bool use_linear = false)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | Input data for SVM transformation. |
| NDArray | label | Class label for the input data. |
| System.Single | margin | The loss function penalizes outputs that lie outside this margin. Default margin is 1. |
| System.Single | regularization_coefficient | Regularization parameter for the SVM. This balances the tradeoff between coefficient size and error. |
| System.Boolean | use_linear | Whether to use L1-SVM objective. L2-SVM objective is used by default. |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
SwapAxis(NDArray, UInt32, UInt32)
Interchanges two axes of an array.
Examples::
x = [[1, 2, 3]])
swapaxes(x, 0, 1) = [[ 1],
[ 2],
[ 3]]
x = [[[ 0, 1],
[ 2, 3]],
[[ 4, 5],
[ 6, 7]]] // (2,2,2) array
swapaxes(x, 0, 2) = [[[ 0, 4],
[ 2, 6]],
[[ 1, 5],
[ 3, 7]]]
Defined in C:\Jenkins\workspace\mxnet\mxnet\src\operator\swapaxis.cc:L70
Declaration
public static NDArray SwapAxis(NDArray data, uint dim1 = 0U, uint dim2 = 0U)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | Input array. |
| System.UInt32 | dim1 | the first axis to be swapped. |
| System.UInt32 | dim2 | the second axis to be swapped. |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
Take(NDArray, NDArray, Int32, TakeMode)
Takes elements from an input array along the given axis.
This function slices the input array along a particular axis with the provided indices.
Given data tensor of rank r >= 1, and indices tensor of rank q, gather entries of the axis
dimension of data (by default outer-most one as axis=0) indexed by indices, and concatenates them
in an output tensor of rank q + (r - 1).
Examples::
x = [4. 5. 6.]
// Trivial case, take the second element along the first axis.
take(x, [1]) = [ 5. ]
// The other trivial case, axis=-1, take the third element along the first axis
take(x, [3], axis=-1, mode='clip') = [ 6. ]
x = [[ 1., 2.],
[ 3., 4.],
[ 5., 6.]]
// In this case we will get rows 0 and 1, then 1 and 2. Along axis 0
take(x, [[0,1],[1,2]]) = [[[ 1., 2.],
[ 3., 4.]],
[[ 3., 4.],
[ 5., 6.]]]
// In this case we will get rows 0 and 1, then 1 and 2 (calculated by wrapping around).
// Along axis 1
take(x, [[0, 3], [-1, -2]], axis=1, mode='wrap') = [[[ 1. 2.]
[ 2. 1.]]
[[ 3. 4.]
[ 4. 3.]]
[[ 5. 6.]
[ 6. 5.]]]
The storage type of ``take`` output depends upon the input storage type:
- take(default, default) = default
- take(csr, default, axis=0) = csr
Defined in C:\Jenkins\workspace\mxnet\mxnet\src\operator\tensor\indexing_op.cc:L695
Declaration
public static NDArray Take(NDArray a, NDArray indices, int axis = 0, TakeMode mode = TakeMode.Clip)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | a | The input array. |
| NDArray | indices | The indices of the values to be extracted. |
| System.Int32 | axis | The axis of input array to be taken.For input tensor of rank r, it could be in the range of [-r, r-1] |
| TakeMode | mode | Specify how out-of-bound indices bahave. Default is "clip". "clip" means clip to the range. So, if all indices mentioned are too large, they are replaced by the index that addresses the last element along an axis. "wrap" means to wrap around. "raise" means to raise an error, not supported yet. |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
Tan(NDArray)
Computes the element-wise tangent of the input array.
The input should be in radians (:math:`2\pi` rad equals 360 degrees).
.. math::
tan([0, \pi/4, \pi/2]) = [0, 1, -inf]
The storage type of ``tan`` output depends upon the input storage type:
- tan(default) = default
- tan(row_sparse) = row_sparse
- tan(csr) = csr
Defined in C:\Jenkins\workspace\mxnet\mxnet\src\operator\tensor\elemwise_unary_op_trig.cc:L83
Declaration
public static NDArray Tan(NDArray data)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | The input array. |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
Tanh(NDArray)
Returns the hyperbolic tangent of the input array, computed element-wise.
.. math::
tanh(x) = sinh(x) / cosh(x)
The storage type of ``tanh`` output depends upon the input storage type:
- tanh(default) = default
- tanh(row_sparse) = row_sparse
- tanh(csr) = csr
Defined in C:\Jenkins\workspace\mxnet\mxnet\src\operator\tensor\elemwise_unary_op_trig.cc:L234
Declaration
public static NDArray Tanh(NDArray data)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | The input array. |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
Tile(NDArray, Shape)
Declaration
public static NDArray Tile(NDArray data, Shape reps)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | |
| Shape | reps |
Returns
| Type | Description |
|---|---|
| NDArray |
Topk(NDArray, Nullable<Int32>, Int32, TopkRetTyp, Boolean, DType)
Declaration
public static NDArray Topk(NDArray data, int? axis, int k = 1, TopkRetTyp ret_typ = TopkRetTyp.Indices, bool is_ascend = false, DType dtype = null)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | |
| System.Nullable<System.Int32> | axis | |
| System.Int32 | k | |
| TopkRetTyp | ret_typ | |
| System.Boolean | is_ascend | |
| DType | dtype |
Returns
| Type | Description |
|---|---|
| NDArray |
Transpose(NDArray, Shape)
Permutes the dimensions of an array.
Examples::
x = [[ 1, 2],
[ 3, 4]]
transpose(x) = [[ 1., 3.],
[ 2., 4.]]
x = [[[ 1., 2.],
[ 3., 4.]],
[[ 5., 6.],
[ 7., 8.]]]
transpose(x) = [[[ 1., 5.],
[ 3., 7.]],
[[ 2., 6.],
[ 4., 8.]]]
transpose(x, axes=(1,0,2)) = [[[ 1., 2.],
[ 5., 6.]],
[[ 3., 4.],
[ 7., 8.]]]
Defined in C:\Jenkins\workspace\mxnet\mxnet\src\operator\tensor\matrix_op.cc:L399
Declaration
public static NDArray Transpose(NDArray data, Shape axes = null)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | Source input |
| Shape | axes | Target axis order. By default the axes will be inverted. |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
Trunc(NDArray)
Return the element-wise truncated value of the input.
The truncated value of the scalar x is the nearest integer i which is closer to
zero than x is. In short, the fractional part of the signed number x is discarded.
Example::
trunc([-2.1, -1.9, 1.5, 1.9, 2.1]) = [-2., -1., 1., 1., 2.]
The storage type of ``trunc`` output depends upon the input storage type:
- trunc(default) = default
- trunc(row_sparse) = row_sparse
- trunc(csr) = csr
Defined in C:\Jenkins\workspace\mxnet\mxnet\src\operator\tensor\elemwise_unary_op_basic.cc:L802
Declaration
public static NDArray Trunc(NDArray data)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | The input array. |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
UnravelIndex(NDArray, Shape)
Converts an array of flat indices into a batch of index arrays. The operator follows numpy conventions so a single multi index is given by a column of the output matrix. The leading dimension may be left unspecified by using -1 as placeholder.
Examples::
A = [22,41,37]
unravel(A, shape=(7,6)) = [[3,6,6],[4,5,1]]
unravel(A, shape=(-1,6)) = [[3,6,6],[4,5,1]]
Defined in C:\Jenkins\workspace\mxnet\mxnet\src\operator\tensor\ravel.cc:L67
Declaration
public static NDArray UnravelIndex(NDArray data, Shape shape = null)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArray | data | Array of flat indices |
| Shape | shape | Shape of the array into which the multi-indices apply. |
Returns
| Type | Description |
|---|---|
| NDArray | returns new NDArray |
UpSampling(NDArrayList, Int32, UpsamplingSampleType, Int32, Int32, UpsamplingMultiInputMode, UInt64)
Performs nearest neighbor/bilinear up sampling to inputs. Bilinear upsampling makes use of deconvolution. Therefore, provide 2 inputs - data and weight.
Declaration
public static NDArray UpSampling(NDArrayList data, int scale, UpsamplingSampleType sample_type, int num_args, int num_filter = 0, UpsamplingMultiInputMode multi_input_mode = UpsamplingMultiInputMode.Concat, ulong workspace = 512UL)
Parameters
| Type | Name | Description |
|---|---|---|
| NDArrayList | data | Array of tensors to upsample. For bilinear upsampling, there should be 2 inputs - 1 data and 1 weight. |
| System.Int32 | scale | Up sampling scale |
| UpsamplingSampleType | sample_type | upsampling method |
| System.Int32 | num_args | Number of inputs to be upsampled. For nearest neighbor upsampling, this can be 1-N; the size of output will be(scaleh_0,scalew_0) and all other inputs will be upsampled to thesame size. For bilinear upsampling this must be 2; 1 input and 1 weight. |