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. IfNone
,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:
- Returns:
ret – The normalized array.
Examples
>>> x = ivy.array([[1., 2.], [3., 4.]]) >>> ivy.l1_normalize(x, axis=1) ivy.array([[0.3333, 0.6667], [0.4286, 0.5714]])
- Array.l1_normalize(self, axis=None, out=None)#
Normalize the array to have unit L1 norm.
- Parameters:
self (
Array
) – Input array.axis (
Optional
[Union
[int
,Tuple
[int
,...
]]]) – Axis or axes along which to normalize. IfNone
, the whole array is normalized. (default:None
)out (
Optional
[Array
]) – Optional output array, for writing the result to. It must have a shape that the (default:None
) inputs broadcast to.
- Return type:
Array
- Returns:
ret – The normalized array.
Examples
>>> x = ivy.array([[1., 2.], [3., 4.]]) >>> x.l1_normalize(axis=1) ivy.array([[0.3333, 0.6667], [0.4286, 0.5714]])
- Container.l1_normalize(self, axis=None, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)#
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 – The input container with leaves to be normalized.
axis (
Optional
[int
]) – The axis along which to normalize. (default:None
)key_chains (
Optional
[Union
[List
[str
],Dict
[str
,str
]]]) – The key-chains to apply or not apply the method to. Default is None. (default:None
)to_apply (
bool
) – If True, the method will be applied to key_chains, otherwise key_chains (default:True
) will be skipped. Default is True.prune_unapplied (
bool
) – Whether to prune key_chains for which the function was not applied. (default:False
) Default is False.map_sequences (
bool
) – Whether to also map method to sequences (lists, tuples). (default:False
) Default is False.out – 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.