Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

Keras · Class

layers.Normalization

Keras Normalization standardizes continuous features using stored mean and variance. Statistics may be supplied directly or learned from data with adapt().

How it works

Normalization is a preprocessing layer for continuous features. It stores feature statistics supplied at construction or computed with adapt(), then transforms inputs using the stored mean and variance; with the default axis, each feature position has separate statistics.

Syntax

keras.layers.Normalization(axis=-1, mean=None, variance=None, invert=False, **kwargs)

Parameters

NameTypeDescription
axisInteger, tuple of integers, or NoneAxes that receive separate mean and variance values; an integer, tuple of integers, or None.
meanArray-likeMean value or values used for normalization.
varianceArray-likeVariance value or values used for normalization.
invertBooleanWhether to reverse the normalization transformation.
**kwargsKeyword argumentsAdditional layer keyword arguments.

Returns

A tensor transformed using the stored mean and variance, or the inverse transformation when invert=True.

Key points

  • Use this layer to standardize continuous-valued inputs before they enter a model.
  • Its transformation targets values centered near zero with a standard deviation near one.
  • Normalization uses stored dataset statistics rather than recalculating them for every call.
  • Statistics can be fixed explicitly or obtained from data with adapt().
  • axis controls which dimensions receive distinct mean and variance values.

Common mistakes

  • Call adapt() before training, evaluation, or prediction when the layer must learn its statistics from data.
  • Explicit mean and variance values must broadcast to the dimensions represented by axis; incompatible shapes fail during building.

Example: Adapt and normalize features

import keras
import numpy as np

x = np.array([[1., 10.], [3., 20.], [5., 30.]])
layer = keras.layers.Normalization(axis=-1)
layer.adapt(x)
print(layer(x).numpy())

Creates one normalization statistic per feature, learns those statistics from the sample data, and applies the resulting transformation.

When to use it

Standardize continuous features

Tabular or numerical model inputs

Apply fixed preprocessing

Input pipelines with known dataset statistics

Invert a normalization transform

Reconstructing values after normalized processing

Interview questions

QHow does the Normalization layer transform data?

It computes normalized values as (input - mean) / sqrt(var). The mean and variance are either passed to the constructor or learned and stored through adapt().

Follow-up: What does adapt() do? It calculates the dataset statistics and saves them as the layer's weights for later calls.

QWhat is the purpose of axis?

The default axis is -1, so the layer keeps separate statistics for each position along the final dimension. Setting axis to None makes it use one scalar mean and variance across all input elements.

Follow-up: Why might axis=None be useful? It applies global normalization when per-feature statistics are not desired.

QWhen must the layer be adapted?

The layer does not require adapt() if mean and variance are supplied during construction. Otherwise, adapt() must run before fit(), evaluate(), or predict() so the layer has statistics available.

Follow-up: What validation applies to supplied statistics? Their shapes must broadcast to the kept axes, or building the layer raises an error.

  • keras.layers.BatchNormalization
  • keras.layers.LayerNormalization
  • keras.layers.RMSNormalization
  • keras.layers.UnitNormalization

Source: Normalization layer. Checked 2026-10-15.