keras-team/keras · error · ValueError

Argument `constant_values` can only be provided when `mode =

Error message

Argument `constant_values` can only be provided when `mode == 'constant'`. Received: mode={mode}

What it means

Error "Argument `constant_values` can only be provided when `mode == 'constant'`. Received: mode={mode}" thrown in keras-team/keras.

Source

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

    new_shape_x1 = ov_opset.constant([-1, 1], Type.i32).output(0)
    new_shape_x2 = ov_opset.constant([1, -1], Type.i32).output(0)

    # Reshape directly from original tensors
    x1_reshaped = ov_opset.reshape(x1, new_shape_x1, False).output(0)
    x2_reshaped = ov_opset.reshape(x2, new_shape_x2, False).output(0)

    result = ov_opset.multiply(x1_reshaped, x2_reshaped).output(0)

    return OpenVINOKerasTensor(result)


def pad(x, pad_width, mode="constant", constant_values=None):
    x = get_ov_output(x)
    pad_value = None
    if constant_values is not None:
        if mode != "constant":
            raise ValueError(
                "Argument `constant_values` can only be "
                "provided when `mode == 'constant'`. "
                f"Received: mode={mode}"
            )
        if not isinstance(
            constant_values, (int, float, np.integer, np.floating)
        ):
            raise ValueError(
                "`pad` operation supports only scalar pad value "
                "in constant mode with the openvino backend. "
                f"Received: constant_values={constant_values}"
            )
        pad_value = ov_opset.constant(
            constant_values, x.get_element_type()
        ).output(0)

    # split pad_width into two tensors pads_begin and pads_end
    pads_begin = []

View on GitHub (pinned to 7a34a03db6)

When it happens

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