tf.keras.layers.UnitNormalization
Unit normalization layer.
Inherits From: Layer
, Module
tf.keras.layers.UnitNormalization(
axis=-1, **kwargs
)
Normalize a batch of inputs so that each input in the batch has a L2 norm
equal to 1 (across the axes specified in axis
).
Example:
data = tf.constant(np.arange(6).reshape(2, 3), dtype=tf.float32)
normalized_data = tf.keras.layers.UnitNormalization()(data)
print(tf.reduce_sum(normalized_data[0, :] ** 2).numpy())
1.0
Args |
axis
|
Integer or list/tuple. The axis or axes to normalize across.
Typically this is the features axis or axes. The left-out axes are
typically the batch axis or axes. Defaults to -1 , the last dimension
in the input.
|
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. Some content is licensed under the numpy license.
Last updated 2022-10-28 UTC.
[null,null,["Last updated 2022-10-28 UTC."],[],[]]