mxnet.np.fabs

fabs(x, out=None, **kwargs)

Calculate the absolute value element-wise.

This function returns the absolute values (positive magnitude) of the data in x. Complex values are not handled, use absolute to find the absolute values of complex data.

Parameters
  • x (ndarray or scalar) – Input array.

  • out (ndarray or None, optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned.

Returns

absolute – An ndarray containing the absolute value of each element in x. This is a scalar if x is a scalar.

Return type

ndarray

Examples

>>> np.fabs(-1)
1.0
>>> np.fabs(np.array([-1.2, 1.2]))s
array([ 1.2,  1.2])