keras-team/keras · error · ValueError
Invalid format for argument `axes`: it should contain two…
Error message
Invalid format for argument `axes`: it should contain two elements. Received: axes={axes} What it means
Length check in Dot.__init__ once `axes` is known to be a list/tuple: it must contain exactly two entries — one axis for the first input, one for the second; a 1- or 3+ element sequence has no valid mapping so the guard fires.
Solutions
- Supply exactly two axis indices, e.g. axes=(1, 2)
- If you want the same axis on both inputs, pass a single int (axes=2) instead of a one-element list
- Drop extra entries that were meant for other parameters
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at keras/src/layers/merging/dot.py:251 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/1f4348f47406b363.
Report an issue: GitHub.
Appendix: source
Thrown at keras/src/layers/merging/dot.py:251
before taking the dot product. If set to `True`, then
the output of the dot product is the cosine proximity
between the two samples.
**kwargs: Standard layer keyword arguments.
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) != 2View on GitHub (pinned to 7a34a03db6)