keras-team/keras · error · ValueError
For layer ' ', received ` ()` argument ` `, but `call()`…
Error message
{error_preamble} For layer '{class_name}', received `{method_name}()` argument `{name}`, but `call()` does not have argument `{expected_call_arg}`. What it means
Keras maps each <name>_shape parameter of build/compute_output_shape to a call() argument named <name> by stripping the _shape suffix. This error fires when the stripped name has no matching parameter in the layer's call() signature, so the shape value has nowhere to be applied.
Solutions
- Add the matching argument to call(): def call(self, inputs, aux) so aux_shape maps to aux
- Remove the orphaned *_shape parameter from build/compute_output_shape
- Keep the two signatures in sync: for every extra call() argument, accept <arg>_shape in build/compute_output_shape
Example fix
# before
class MyLayer(keras.layers.Layer):
def call(self, inputs):
...
def compute_output_shape(self, input_shape, aux_shape):
... # ValueError
# after
class MyLayer(keras.layers.Layer):
def call(self, inputs, aux=None):
...
def compute_output_shape(self, input_shape, aux_shape=None):
... Defensive patterns
Strategy: validation
Validate before calling
import inspect
call_args = set(inspect.signature(MyLayer.call).parameters) - {'self'}
shape_args = {p.removesuffix('_shape') for p in inspect.signature(MyLayer.compute_output_shape).parameters if p != 'self'}
assert shape_args <= call_args, shape_args - call_args Prevention
- Keep call() and compute_output_shape/build signatures synchronized
- Update *_shape parameters whenever renaming call() arguments
- Add a CI signature-consistency check for custom layers
When it happens
Trigger: Defining compute_output_shape(self, input_shape, aux_shape) when call(self, inputs) has no aux parameter; renaming a call() argument without updating compute_output_shape; leftover *_shape params after refactoring.
Common situations: Copy-pasting a compute_output_shape override from another layer whose call() signature differs; version upgrades where call() signatures changed; stale overrides after deleting a call() argument.
Related errors
- A `Concatenate` layer should be called on a list of inputs…
- For layer ' ', Received ` ()` argument ` `, which does not…
- A `Concatenate` layer requires inputs with matching shapes…
- A `Concatenate` layer should be called on a list of at…
- A FeatureSpace can only be called with a dict. Received…
AI-assisted analysis of keras-team/keras@7a34a03db6 (2026-08-25).
Data as JSON: /api/errors/4af21681b918ce46.
Report an issue: GitHub.
Appendix: source
Thrown at keras/src/layers/layer.py:2063
# Multiple args: check that all names line up.
kwargs = {}
for name in expected_names:
method_name = target_fn.__name__
error_preamble = (
f"For a `{method_name}()` method with more than one argument, all "
"arguments should have a `_shape` suffix and match an argument "
f"from `call()`. E.g. `{method_name}(self, foo_shape, bar_shape)` "
)
if not name.endswith("_shape"):
raise ValueError(
f"{error_preamble} For layer '{class_name}', "
f"Received `{method_name}()` argument "
f"`{name}`, which does not end in `_shape`."
)
expected_call_arg = utils.removesuffix(name, "_shape")
if expected_call_arg not in call_spec.arguments_dict:
raise ValueError(
f"{error_preamble} For layer '{class_name}', "
f"received `{method_name}()` argument "
f"`{name}`, but `call()` does not have argument "
f"`{expected_call_arg}`."
)
if name in shapes_dict:
kwargs[name] = shapes_dict[name]
return kwargs
class CallContext:
def __init__(self, entry_layer):
self.entry_layer = entry_layer
def get_value(self, arg_name, default=None):
"""Get the context value for `arg_name`, or `default` if unset."""
return getattr(self, arg_name, default)View on GitHub (pinned to 7a34a03db6)