keras-team/keras · error · ValueError
A `Dot` layer should be called on exactly 2 inputs…
Error message
A `Dot` layer should be called on exactly 2 inputs. Received: inputs={inputs} What it means
Runtime call-time check in Dot's call path: unlike the build-time shape check, this validates the actual inputs passed at __call__ time and requires exactly two tensors; more, fewer, or a single non-list input triggers it.
Solutions
- Pass exactly two tensors as a list: dot_layer([x1, x2])
- Wrap a single input in a list even if you split it first: dot_layer([x[:, :d], x[:, d:]])
- For more than two inputs, reduce pairwise: keras.ops.sum of successive Dot outputs
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at keras/src/layers/merging/dot.py:296 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/380799de62f0dda5.
Report an issue: GitHub.
Appendix: source
Thrown at keras/src/layers/merging/dot.py:296
return
if isinstance(self.axes, int):
if self.axes < 0:
axes = [self.axes % len(shape1), self.axes % len(shape2)]
else:
axes = [self.axes] * 2
else:
axes = self.axes
if shape1[axes[0]] != shape2[axes[1]]:
raise ValueError(
f"Incompatible input shapes: "
f"axis values {shape1[axes[0]]} (at axis {axes[0]}) != "
f"{shape2[axes[1]]} (at axis {axes[1]}). "
f"Full input shapes: {shape1}, {shape2}"
)
def _merge_function(self, inputs):
if len(inputs) != 2:
raise ValueError(
f"A `Dot` layer should be called on exactly 2 inputs. "
f"Received: inputs={inputs}"
)
x1 = inputs[0]
x2 = inputs[1]
if isinstance(self.axes, int):
if self.axes < 0:
axes = [
self.axes % len(x1.shape),
self.axes % len(x2.shape),
]
else:
axes = [self.axes] * 2
else:
axes = []
for i in range(len(self.axes)):
if self.axes[i] < 0:View on GitHub (pinned to 7a34a03db6)