keras-team/keras · error · RuntimeError

`convert_to_numpy` failed to convert the tensor.

Error message

`convert_to_numpy` failed to convert the tensor.

What it means

Error "`convert_to_numpy` failed to convert the tensor." thrown in keras-team/keras.

Source

Thrown at keras/src/backend/openvino/core.py:950

        # fall back to the slow path.
        pass
    try:
        ov_result = x.output
        casted_from_bool = False
        if ov_result.get_element_type() == Type.boolean:
            ov_result = ov_opset.convert(ov_result, Type.i32).output(0)
            casted_from_bool = True
        ov_model = Model(results=[ov_result], parameters=[])
        ov_compiled_model = compile_model(
            ov_model,
            get_device(),
            config={"INFERENCE_PRECISION_HINT": "f32"},
        )
        result = ov_compiled_model({})[0]
        if casted_from_bool:
            result = result.astype(bool)
    except Exception as inner_exception:
        raise RuntimeError(
            "`convert_to_numpy` failed to convert the tensor."
        ) from inner_exception
    data = np.array(result)
    # Same byte-reinterpretation issue applies to inference results.
    if x.dtype == "bfloat16" and data.dtype != ml_dtypes.bfloat16:
        data = data.view(ml_dtypes.bfloat16)
    return data


def is_tensor(x):
    if isinstance(x, OpenVINOKerasTensor):
        return True
    if isinstance(x, ov.Tensor):
        return True
    return False


def shape(x):

View on GitHub (pinned to 7a34a03db6)

When it happens

Trigger: Thrown at keras/src/backend/openvino/core.py:950 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/ce75620acced1355. Report an issue: GitHub.