keras-team/keras · error · ValueError

Shape of weights must be consistent with shape of a along sp

Error message

Shape of weights must be consistent with shape of a along specified axis.

What it means

Error "Shape of weights must be consistent with shape of a along specified axis." thrown in keras-team/keras.

Source

Thrown at keras/src/backend/openvino/numpy.py:851

            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 "
                "along specified axis."
            )

    if axis is None:
        flatten_shape = ov_opset.constant([-1], Type.i32).output(0)
        x = ov_opset.reshape(x, flatten_shape, False).output(0)
        if weights is not None:

View on GitHub (pinned to 7a34a03db6)

When it happens

Trigger: Thrown at keras/src/backend/openvino/numpy.py:851 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/e516186c648ebafd. Report an issue: GitHub.