keras-team/keras · error · ValueError
Invalid format for argument `axes`: list elements should be…
Error message
Invalid format for argument `axes`: list elements should be integers. Received: axes={axes} What it means
Element-type check in Dot.__init__ after the length check: a 2-element axes sequence must contain only ints; floats (e.g. 2.0), strings, or None elements would break axis indexing downstream, so they are rejected here.
Solutions
- Cast each element to int: axes=[int(a) for a in axes]
- Fix configs that loaded axes as floats/strings (common with JSON round-trips) before constructing Dot
- Negative ints are fine; keep them as ints, not floats like -1.0
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at keras/src/layers/merging/dot.py:256 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/7437d6cbdf0dd3b3.
Report an issue: GitHub.
Appendix: source
Thrown at keras/src/layers/merging/dot.py:256
Returns:
A tensor, the dot product of the samples from the inputs.
"""
def __init__(self, axes, normalize=False, **kwargs):
super().__init__(**kwargs)
if not isinstance(axes, int):
if not isinstance(axes, (list, tuple)):
raise TypeError(
f"Invalid type for argument `axes`: it should be "
f"a list or an int. Received: axes={axes}"
)
if len(axes) != 2:
raise ValueError(
f"Invalid format for argument `axes`: it should contain "
f"two elements. Received: axes={axes}"
)
if not isinstance(axes[0], int) or not isinstance(axes[1], int):
raise ValueError(
f"Invalid format for argument `axes`: list elements should "
f"be integers. Received: axes={axes}"
)
self.axes = axes
self.normalize = normalize
self.supports_masking = True
self._reshape_required = False
def build(self, input_shape):
# Used purely for shape validation.
if (
not isinstance(input_shape[0], (tuple, list))
or len(input_shape) != 2
):
raise ValueError(
f"A `Dot` layer should be called on a list of 2 inputs. "
f"Received: input_shape={input_shape}"
)View on GitHub (pinned to 7a34a03db6)