e3x.ops.safe.normalize
- e3x.ops.safe.normalize(x, axis=None)[source]
Normalize x using the L2-norm of x along the specified axis.
If x has a norm of almost zero, it is left unnormalized, because normalization becomes numerically unstable.
- Parameters:
x (
<class 'Float[Array, '...']'>) – Input array.axis (
Union[int,Tuple[int,...],None], default:None) – Axis or axes along which the L2-norm is computed. The default, axis=None, will compute the norm of all elements of the input array (as if it was one large vector). If axis is negative it counts from the last to the first axis.
- Return type:
- Returns:
The normalized array with the same shape as x.