LayerNormalization
¶
LayerNormalization(
num_features: int,
eps: float = 1e-05,
affine: bool = True,
mode: Literal["graph", "node"] = "graph",
)
Bases: Module
Applies layer normalization over each individual example in a batch of features as described in the Layer Normalization paper.
The mean and standard-deviation are calculated across all nodes and all node channels separately for each object in a mini-batch.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
num_features
|
int
|
Size of each input sample. |
required |
eps
|
float
|
A value added to the denominator for numerical
stability. (default: |
1e-05
|
affine
|
bool
|
If set to |
True
|
mode
|
Literal['graph', 'node']
|
The normalization mode to use for layer
normalization ( |
'graph'
|
Methods:
| Name | Description |
|---|---|
__call__ |
Normalizes the features. |
Source code in mlx_graphs/nn/norm/layer_norm.py
__call__
¶
__call__(
features: array,
batch: Optional[array] = None,
batch_size: Optional[int] = None,
) -> array
Normalizes the features.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
features
|
array
|
Features of shape |
required |
batch
|
Optional[array]
|
Graph of each node, of shape |
None
|
batch_size
|
Optional[int]
|
Number of graphs. Default: |
None
|
Returns:
| Type | Description |
|---|---|
array
|
The normalized features. |
Source code in mlx_graphs/nn/norm/layer_norm.py
from mlx_graphs.nn import LayerNormalization · mlx_graphs/nn/norm/layer_norm.py