Norms#
- class ivy.data_classes.array.norms._ArrayWithNorms[source]#
Bases:
ABC
- _abc_impl = <_abc._abc_data object>#
- layer_norm(normalized_idxs, /, *, scale=None, offset=None, eps=1e-05, new_std=1.0, out=None)[source]#
ivy.Array instance method variant of ivy.layer_norm. This method simply wraps the function, and so the docstring for ivy.layer_norm also applies to this method with minimal changes.
- Parameters:
self (
Array
) – Input arraynormalized_idxs (
List
[int
]) – Indices to apply the normalization to.scale (
Optional
[Union
[Array
,NativeArray
]], default:None
) – Learnable gamma variables for elementwise post-multiplication, default isNone
.offset (
Optional
[Union
[Array
,NativeArray
]], default:None
) – Learnable beta variables for elementwise post-addition, default isNone
.eps (
float
, default:1e-05
) – small constant to add to the denominator. Default is1e-05
.new_std (
float
, default:1.0
) – The standard deviation of the new normalized values. Default is 1.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 layer after applying layer normalization.
Examples
>>> x = ivy.array([[0.0976, -0.3452, 1.2740], ... [0.1047, 0.5886, 1.2732], ... [0.7696, -1.7024, -2.2518]]) >>> norm = x.layer_norm([0, 1], eps=0.001, ... new_std=1.5, scale=0.5, offset=[0.5, 0.02, 0.1]) >>> print(norm) ivy.array([[ 0.826, -0.178, 0.981 ], [ 0.831, 0.421, 0.981 ], [ 1.26 , -1.05 , -1.28 ]])
This should have hopefully given you an overview of the norms submodule, if you have any questions, please feel free to reach out on our discord!