keras-team/keras · error · ValueError
Axis must be specified when shapes of a and weights differ.
Error message
Axis must be specified when shapes of a and weights differ.
What it means
Error "Axis must be specified when shapes of a and weights differ." thrown in keras-team/keras.
Source
Thrown at keras/src/backend/openvino/numpy.py:844
if weights is not None:
weights = get_ov_output(weights)
if weights_keras is not None:
x_shape = (
x_keras.shape
if hasattr(x_keras, "shape")
else x.get_partial_shape()
)
weights_shape = (
weights_keras.shape
if hasattr(weights_keras, "shape")
else weights.get_partial_shape()
)
if len(weights_shape) == 1 and len(x_shape) > 1:
if axis is None or (
isinstance(axis, (list, tuple)) and len(axis) != 1
):
raise ValueError(
"Axis must be specified when shapes of a and weights "
"differ."
)
axis_val = axis[0] if isinstance(axis, (list, tuple)) else axis
axis_val = canonicalize_axis(axis_val, len(x_shape))
if weights_shape[0] != x_shape[axis_val]:
raise ValueError(
"Shape of weights must be consistent with shape of a "
"along specified axis."
)
elif x_shape != weights_shape:
if axis is None:
raise ValueError(
"Axis must be specified when shapes of a and weights "
"differ."
)
raise ValueError(
"Shape of weights must be consistent with shape of a "View on GitHub (pinned to 7a34a03db6)
When it happens
Trigger: Thrown at keras/src/backend/openvino/numpy.py:844 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/f513d9ce88edf298.
Report an issue: GitHub.