keras-team/keras · error · ValueError
Argument `input_tensors` must contain a single tensor.
Error message
Argument `input_tensors` must contain a single tensor.
What it means
When cloning a Sequential model onto new inputs, input_tensors must reduce to exactly one tensor because a Sequential model has a single input. A list/tuple with zero or two-plus tensors raises this ValueError.
Source
Thrown at keras/src/models/cloning.py:308
new_layers = [clone_function(layer) for layer in model.layers]
if isinstance(model._layers[0], InputLayer):
ref_input_layer = model._layers[0]
input_name = ref_input_layer.name
input_batch_shape = ref_input_layer.batch_shape
input_dtype = ref_input_layer._dtype
input_optional = ref_input_layer.optional
else:
input_name = None
input_dtype = None
input_batch_shape = None
input_optional = False
if input_tensors is not None:
if isinstance(input_tensors, (list, tuple)):
if len(input_tensors) != 1:
raise ValueError(
"Argument `input_tensors` must contain a single tensor."
)
input_tensors = input_tensors[0]
if not isinstance(input_tensors, backend.KerasTensor):
raise ValueError(
"Argument `input_tensors` must be a KerasTensor. "
f"Received invalid value: input_tensors={input_tensors}"
)
inputs = Input(
tensor=input_tensors,
name=input_name,
optional=input_optional,
)
new_layers = [inputs] + new_layers
else:
if input_batch_shape is not None:
inputs = Input(
batch_shape=input_batch_shape,View on GitHub (pinned to 7a34a03db6)
Solutions
- Pass the single tensor directly (no list), or a one-element list: input_tensors=[t].
- For genuinely multi-input models, use a Functional model instead of Sequential.
Example fix
# before clone = keras.models.clone_model(seq_model, input_tensors=[t1, t2]) # after clone = keras.models.clone_model(seq_model, input_tensors=t1)
Defensive patterns
Strategy: validation
Validate before calling
if isinstance(input_tensors, (list, tuple)):
assert len(input_tensors) == 1, 'Sequential clone takes exactly one input tensor'
input_tensors = input_tensors[0] Prevention
- Pass a bare tensor for single-input models.
- Use Functional models for multi-input architectures.
When it happens
Trigger: clone_model(seq_model, input_tensors=[]) or input_tensors=[t1, t2] - a list whose length is not 1.
Common situations: Generic cloning code that always wraps inputs in a list; adapting multi-input Functional examples to Sequential.
Related errors
- `call_function` argument is not supported with Sequential mo
- Expected `model` argument to be a `Sequential` model instanc
- Unexpected keyword argument(s): {tuple(kwargs.keys())}
- Arguments `clone_function` and `input_tensors` are only supp
- Argument `call_function` is only supported for Functional mo
AI-assisted analysis of keras-team/keras@7a34a03db6 (2026-08-25).
Data as JSON: /api/errors/d87f87ab8a137f22.
Report an issue: GitHub.