tf.keras.layers.LayerNormalization
Stay organized with collections
Save and categorize content based on your preferences.
Layer normalization layer (Ba et al., 2016).
Inherits From: Layer
tf.keras.layers.LayerNormalization(
axis=-1, epsilon=0.001, center=True, scale=True, beta_initializer='zeros',
gamma_initializer='ones', beta_regularizer=None, gamma_regularizer=None,
beta_constraint=None, gamma_constraint=None, trainable=True, name=None, **kwargs
)
Normalize the activations of the previous layer for each given example in a
batch independently, rather than across a batch like Batch Normalization.
i.e. applies a transformation that maintains the mean activation within each
example close to 0 and the activation standard deviation close to 1.
Arguments |
axis
|
Integer or List/Tuple. The axis that should be normalized
(typically the features axis).
|
epsilon
|
Small float added to variance to avoid dividing by zero.
|
center
|
If True, add offset of beta to normalized tensor.
If False, beta is ignored.
|
scale
|
If True, multiply by gamma .
If False, gamma is not used.
When the next layer is linear (also e.g. nn.relu ),
this can be disabled since the scaling
will be done by the next layer.
|
beta_initializer
|
Initializer for the beta weight.
|
gamma_initializer
|
Initializer for the gamma weight.
|
beta_regularizer
|
Optional regularizer for the beta weight.
|
gamma_regularizer
|
Optional regularizer for the gamma weight.
|
beta_constraint
|
Optional constraint for the beta weight.
|
gamma_constraint
|
Optional constraint for the gamma weight.
|
trainable
|
Boolean, if True the variables will be marked as trainable.
|
Arbitrary. Use the keyword argument input_shape
(tuple of integers, does not include the samples axis)
when using this layer as the first layer in a model.
Output shape:
Same shape as input.
References:
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2020-10-01 UTC.
[null,null,["Last updated 2020-10-01 UTC."],[],[],null,["# tf.keras.layers.LayerNormalization\n\n\u003cbr /\u003e\n\n|-----------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------|\n| [TensorFlow 2 version](/api_docs/python/tf/keras/layers/LayerNormalization) | [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/python/keras/layers/normalization.py#L874-L1046) |\n\nLayer normalization layer (Ba et al., 2016).\n\nInherits From: [`Layer`](../../../tf/keras/layers/Layer)\n\n#### View aliases\n\n\n**Compat aliases for migration**\n\nSee\n[Migration guide](https://www.tensorflow.org/guide/migrate) for\nmore details.\n\n[`tf.compat.v1.keras.layers.LayerNormalization`](/api_docs/python/tf/keras/layers/LayerNormalization), \\`tf.compat.v2.keras.layers.LayerNormalization\\`\n\n\u003cbr /\u003e\n\n tf.keras.layers.LayerNormalization(\n axis=-1, epsilon=0.001, center=True, scale=True, beta_initializer='zeros',\n gamma_initializer='ones', beta_regularizer=None, gamma_regularizer=None,\n beta_constraint=None, gamma_constraint=None, trainable=True, name=None, **kwargs\n )\n\nNormalize the activations of the previous layer for each given example in a\nbatch independently, rather than across a batch like Batch Normalization.\ni.e. applies a transformation that maintains the mean activation within each\nexample close to 0 and the activation standard deviation close to 1.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Arguments --------- ||\n|---------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `axis` | Integer or List/Tuple. The axis that should be normalized (typically the features axis). |\n| `epsilon` | Small float added to variance to avoid dividing by zero. |\n| `center` | If True, add offset of `beta` to normalized tensor. If False, `beta` is ignored. |\n| `scale` | If True, multiply by `gamma`. If False, `gamma` is not used. When the next layer is linear (also e.g. [`nn.relu`](../../../tf/nn/relu)), this can be disabled since the scaling will be done by the next layer. |\n| `beta_initializer` | Initializer for the beta weight. |\n| `gamma_initializer` | Initializer for the gamma weight. |\n| `beta_regularizer` | Optional regularizer for the beta weight. |\n| `gamma_regularizer` | Optional regularizer for the gamma weight. |\n| `beta_constraint` | Optional constraint for the beta weight. |\n| `gamma_constraint` | Optional constraint for the gamma weight. |\n| `trainable` | Boolean, if `True` the variables will be marked as trainable. |\n\n\u003cbr /\u003e\n\n#### Input shape:\n\nArbitrary. Use the keyword argument `input_shape`\n(tuple of integers, does not include the samples axis)\nwhen using this layer as the first layer in a model.\n\n#### Output shape:\n\nSame shape as input.\n\n#### References:\n\n- [Layer Normalization](https://arxiv.org/abs/1607.06450)"]]