keras-team/keras · error · ValueError
`inputs` should be a list. Received: inputs={inputs}
Error message
`inputs` should be a list. Received: inputs={inputs} What it means
Concatenate.compute_mask validates that inputs is a list/tuple when a mask is supplied. A single tensor input (or non-sequence) together with a mask argument triggers this error.
Source
Thrown at keras/src/layers/merging/concatenate.py:128
f"Received: input_shape={input_shape}"
)
input_shapes = input_shape
output_shape = list(input_shapes[0])
for shape in input_shapes[1:]:
if output_shape[self.axis] is None or shape[self.axis] is None:
output_shape[self.axis] = None
break
output_shape[self.axis] += shape[self.axis]
return tuple(output_shape)
def compute_mask(self, inputs, mask=None):
if mask is None:
return None
if not isinstance(mask, (tuple, list)):
raise ValueError(f"`mask` should be a list. Received mask={mask}")
if not isinstance(inputs, (tuple, list)):
raise ValueError(
f"`inputs` should be a list. Received: inputs={inputs}"
)
if len(mask) != len(inputs):
raise ValueError(
"The lists `inputs` and `mask` should have the same length. "
f"Received: inputs={inputs} of length {len(inputs)}, and "
f"mask={mask} of length {len(mask)}"
)
if all(m is None for m in mask):
return None
# Make a list of masks while making sure
# the dimensionality of each mask
# is the same as the corresponding input.
masks = []
for input_i, mask_i in zip(inputs, mask):
if mask_i is None:
# Input is unmasked. Append all 1s to masks,
masks.append(ops.ones_like(input_i, dtype="bool"))View on GitHub (pinned to 7a34a03db6)
Solutions
- Always pass inputs as a list matching the layer's call structure
- Mirror the exact input structure used in __call__ when calling compute_mask
- Add a structure check in wrappers before delegating
Example fix
# before m = concat.compute_mask(x, mask=[m1, m2]) # after m = concat.compute_mask([x1, x2], mask=[m1, m2])
Defensive patterns
Strategy: validation
Validate before calling
assert isinstance(inputs, (list, tuple)), 'inputs must be a list when mask is given'
Type guard
def is_input_list(x) -> bool:
return isinstance(x, (list, tuple)) Prevention
- Keep compute_mask call structure identical to __call__
- Wrap inputs in lists in subclasses that override compute_mask
When it happens
Trigger: compute_mask(x, mask=[m1, m2]) called with a bare tensor; custom subclasses forwarding unwrapped inputs to the parent implementation.
Common situations: Direct compute_mask calls in tests or shape utilities; custom merge subclasses with altered input arity.
Related errors
- `inputs` should be a list. Received: inputs={inputs}
- A `Concatenate` layer should be called on a list of at least
- A `Concatenate` layer should be called on a list of inputs.
- `mask` should be a list. Received mask={mask}
- The lists `inputs` and `mask` should have the same length. R
AI-assisted analysis of keras-team/keras@7a34a03db6 (2026-08-25).
Data as JSON: /api/errors/7bf4f18924714c24.
Report an issue: GitHub.