View source on GitHub
|
Functional interface for the batch normalization layer from_config(Ioffe et al., 2015).
tf.compat.v1.layers.batch_normalization(
inputs,
axis=-1,
momentum=0.99,
epsilon=0.001,
center=True,
scale=True,
beta_initializer=tf.compat.v1.zeros_initializer(),
gamma_initializer=tf.compat.v1.ones_initializer(),
moving_mean_initializer=tf.compat.v1.zeros_initializer(),
moving_variance_initializer=tf.compat.v1.ones_initializer(),
beta_regularizer=None,
gamma_regularizer=None,
beta_constraint=None,
gamma_constraint=None,
training=False,
trainable=True,
name=None,
reuse=None,
renorm=False,
renorm_clipping=None,
renorm_momentum=0.99,
fused=None,
virtual_batch_size=None,
adjustment=None
)
Migrate to TF2
This API is a legacy api that is only compatible with eager execution and
tf.function if you combine it with
tf.compat.v1.keras.utils.track_tf1_style_variables
Please refer to tf.layers model mapping section of the migration guide to learn how to use your TensorFlow v1 model in TF2 with Keras.
The corresponding TensorFlow v2 layer is
tf.keras.layers.BatchNormalization.
The batch updating pattern with
tf.control_dependencies(tf.GraphKeys.UPDATE_OPS) should not be used in
native TF2. Consult the tf.keras.layers.BatchNormalization documentation
for further information.
Structural Mapping to Native TF2
None of the supported arguments have changed name.
Before:
x_norm = tf.compat.v1.layers.batch_normalization(x)
After:
To migrate code using TF1 functional layers use the Keras Functional API:
x = tf.keras.Input(shape=(28, 28, 1),)
y = tf.keras.layers.BatchNormalization()(x)
model = tf.keras.Model(x, y)
How to Map Arguments
| TF1 Arg Name | TF2 Arg Name | Note |
|---|---|---|
name |
name |
Layer base class |
trainable |
trainable |
Layer base class |
axis |
axis |
- |
momentum |
momentum |
- |
epsilon |
epsilon |
- |
center |
center |
- |
scale |
scale |
- |
beta_initializer |
beta_initializer |
- |
gamma_initializer |
gamma_initializer |
- |
moving_mean_initializer |
moving_mean_initializer |
- |
beta_regularizer |
`beta_regularizer' | - |
gamma_regularizer |
`gamma_regularizer' | - |
beta_constraint |
`beta_constraint' | - |
gamma_constraint |
`gamma_constraint' | - |
renorm |
Not supported | - |
renorm_clipping |
Not supported | - |
renorm_momentum |
Not supported | - |
fused |
Not supported | - |
virtual_batch_size |
Not supported | - |
adjustment |
Not supported | - |
View source on GitHub