keras-team/keras · error · ValueError
Layer supplied to Wrapper isn't a supported layer type…
Error message
Layer {layer} supplied to Wrapper isn't a supported layer type. Please ensure wrapped layer is a valid Keras layer. What it means
Type guard in Wrapper.__init__ (base of TimeDistributed and Bidirectional): the `layer` argument must be a Keras Layer instance; passing a model, function, tensor, or other object fails the isinstance check and is rejected with the object echoed.
Solutions
- Pass an instance of a Keras layer, e.g. TimeDistributed(layers.Dense(8))
- Wrap custom logic in a keras.layers.Layer subclass before using it as the wrapped layer
- Instantiate the class instead of passing the class itself
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at keras/src/layers/core/wrapper.py:20 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/c73a3c9fdb1c6aff.
Report an issue: GitHub.
Appendix: source
Thrown at keras/src/layers/core/wrapper.py:20
from keras.src.layers.layer import Layer
from keras.src.saving import serialization_lib
@keras_export("keras.layers.Wrapper")
class Wrapper(Layer):
"""Abstract wrapper base class.
Wrappers take another layer and augment it in various ways.
Do not use this class as a layer, it is only an abstract base class.
Two usable wrappers are the `TimeDistributed` and `Bidirectional` layers.
Args:
layer: The layer to be wrapped.
"""
def __init__(self, layer, **kwargs):
if not isinstance(layer, Layer):
raise ValueError(
f"Layer {layer} supplied to Wrapper isn't "
"a supported layer type. Please "
"ensure wrapped layer is a valid Keras layer."
)
super().__init__(**kwargs)
self.layer = layer
def build(self, input_shape=None):
if not self.layer.built:
self.layer.build(input_shape)
self.layer.built = True
def get_config(self):
config = {"layer": serialization_lib.serialize_keras_object(self.layer)}
base_config = super().get_config()
return {**base_config, **config}
@classmethodView on GitHub (pinned to 7a34a03db6)