jax.numpy.fabs#
- jax.numpy.fabs(x, /)[source]#
Compute the element-wise absolute values of the real-valued input.
JAX implementation of
numpy.fabs
.- Parameters:
x (ArrayLike) – input array or scalar. Must not have a complex dtype.
- Returns:
An array with same shape as
x
and dtype float, containing the element-wise absolute values.- Return type:
See also
jax.numpy.absolute()
: Computes the absolute values of the input including complex dtypes.jax.numpy.abs()
: Computes the absolute values of the input including complex dtypes.
Examples
For integer inputs:
>>> x = jnp.array([-5, -9, 1, 10, 15]) >>> jnp.fabs(x) Array([ 5., 9., 1., 10., 15.], dtype=float32)
For float type inputs:
>>> x1 = jnp.array([-1.342, 5.649, 3.927]) >>> jnp.fabs(x1) Array([1.342, 5.649, 3.927], dtype=float32)
For boolean inputs:
>>> x2 = jnp.array([True, False]) >>> jnp.fabs(x2) Array([1., 0.], dtype=float32)