keras-team/keras · error · NotImplementedError
Unsupported data type
Error message
Unsupported data type: {type(data)} What it means
Raised by a dispatch guard in Normalization (data-adapt helpers) when the object passed as data is none of the supported container types (dataset/iterator/NumPy array/etc.), so the layer cannot iterate over it to accumulate mean and variance. The offending value is the data argument itself, whose type is echoed in the message.
Solutions
- Pass a supported data type to adapt(): a tf.data.Dataset, a NumPy array, or a tensor/compatible array-convertible object
- Wrap custom Python iterables or generators in tf.data.Dataset.from_generator(...) or .from_tensor_slices(...)
- Convert lists to np.asarray before calling adapt()
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at keras/src/layers/preprocessing/normalization.py:409 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of keras-team/keras@7a34a03db6 (2026-08-25).
Data as JSON: /api/errors/18f41b2894e2dde9.
Report an issue: GitHub.
Appendix: source
Thrown at keras/src/layers/preprocessing/normalization.py:409
batch_weight = float(batch_count) / total_count
existing_weight = 1.0 - batch_weight
new_total_mean = (
total_mean * existing_weight + batch_mean * batch_weight
)
# The variance is computed using the lack-of-fit sum of squares
# formula (see
# https://en.wikipedia.org/wiki/Lack-of-fit_sum_of_squares).
total_var = (
total_var + (total_mean - new_total_mean) ** 2
) * existing_weight + (
batch_var + (batch_mean - new_total_mean) ** 2
) * batch_weight
total_mean = new_total_mean
progbar.update(i + 1)
progbar.update(steps if steps is not None else i + 1, finalize=True)
else:
raise NotImplementedError(f"Unsupported data type: {type(data)}")
self.adapt_mean.assign(total_mean)
self.adapt_variance.assign(total_var)
self.finalize_state()
def finalize_state(self):
if self.input_mean is not None or not self.built:
return
# In the adapt case, we make constant tensors for mean and variance with
# proper broadcast shape and dtype each time `finalize_state` is called.
self.mean = ops.reshape(self.adapt_mean, self._broadcast_shape)
self.mean = ops.cast(self.mean, self.compute_dtype)
self.variance = ops.reshape(self.adapt_variance, self._broadcast_shape)
self.variance = ops.cast(self.variance, self.compute_dtype)
def call(self, inputs):
# This layer can be called in tf.dataView on GitHub (pinned to 7a34a03db6)