l1_normalize#

ivy.l1_normalize(x, /, *, axis=None, out=None)[source]#

Normalize the input array along the given axis to have L1 norm equal to 1.

Parameters:
  • x (Union[Array, NativeArray]) – Input array.

  • axis (Optional[Union[int, Tuple[int, ...]]], default: None) –

    Axis or axes along which to normalize. If None,

    the whole array is normalized.

  • out (Optional[Array], default: None) –

    Optional output array, for writing the result to.

    It must have a shape that the inputs broadcast to.

Return type:

Array

Returns:

ret – The normalized array.

Examples

>>> x = ivy.array([[1., 2.], [3., 4.]])
>>> y = ivy.l1_normalize(x, axis=1)
>>> print(y)
ivy.array([[0.33333334, 1.33333337],
       [1.28571439, 2.28571439]])
Array.l1_normalize(self, axis=None, out=None)[source]#

Normalize the array to have unit L1 norm.

Parameters:
  • self (Array) – Input array.

  • axis (Optional[Union[int, Tuple[int, ...]]], default: None) – Axis or axes along which to normalize. If None, the whole array is normalized.

  • out (Optional[Array], default: None) – Optional output array, for writing the result to. It must have a shape that the inputs broadcast to.

Return type:

Array

Returns:

ret – The normalized array.

Examples

>>> x = ivy.array([[1., 2.], [3., 4.]])
>>> y = x.l1_normalize(axis=1)
>>> print(y)
ivy.array([[0.33333334, 1.33333337],
       [1.28571439, 2.28571439]])
Container.l1_normalize(self, axis=None, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

ivy.Container instance method variant of ivy.l1_normalize. This method simply wraps the function, and so the docstring for ivy.l1_normalize also applies to this method with minimal changes.

Parameters:
  • self (Container) – The input container with leaves to be normalized.

  • axis (Optional[Union[int, Container]], default: None) – The axis along which to normalize.

  • key_chains (Optional[Union[List[str], Dict[str, str], Container]], default: None) – The key-chains to apply or not apply the method to. Default is None.

  • to_apply (Union[bool, Container], default: True) – If True, the method will be applied to key_chains, otherwise key_chains will be skipped. Default is True.

  • prune_unapplied (Union[bool, Container], default: False) – Whether to prune key_chains for which the function was not applied. Default is False.

  • map_sequences (Union[bool, Container], default: False) – Whether to also map method to sequences (lists, tuples). Default is False.

  • out (Optional[Container], default: None) – Optional output container, for writing the result to. It must have a shape that the inputs broadcast to.

Return type:

Container

Returns:

ret – A container containing the normalized leaves.