keras-team/keras · error · ValueError
`shape` argument cannot contain `None`. Received: shape=
Error message
`shape` argument cannot contain `None`. Received: shape={shape} What it means
Raised by keras.ops.numpy.unravel_index in the OpenVINO backend when the shape argument contains None (a dynamic dimension). Converting flat indices to multi-indexes needs concrete dimension sizes for the div/mod arithmetic.
Solutions
- Pass shape with all-integer dimensions
- Resolve dynamic shapes to concrete ints (e.g. from ops.shape at runtime) before calling unravel_index
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at keras/src/backend/openvino/numpy.py:5112 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/729f8d2787a63e20.
Report an issue: GitHub.
Appendix: source
Thrown at keras/src/backend/openvino/numpy.py:5112
else:
x_final = ov_opset.constant(dx, dtype=y_type).output(0)
result = ov_opset.multiply(y_final, x_final).output(0)
const_axis = ov_opset.constant([axis], Type.i64).output(0)
result = ov_opset.reduce_sum(result, const_axis, False).output(0)
return OpenVINOKerasTensor(result)
def unravel_index(indices, shape):
indices = get_ov_output(indices)
if not indices.get_element_type().is_integral():
indices = ov_opset.convert(indices, Type.i64).output(0)
indices_dtype = indices.get_element_type()
if None in shape:
raise ValueError(
f"`shape` argument cannot contain `None`. Received: shape={shape}"
)
if isinstance(shape, tuple):
shape = list(shape)
# Handle negative indices
total_size = math.prod(shape)
total_size_const = ov_opset.constant(total_size, indices_dtype).output(0)
zero = ov_opset.constant(0, indices_dtype).output(0)
is_negative = ov_opset.less(indices, zero).output(0)
indices = ov_opset.select(
is_negative, ov_opset.add(indices, total_size_const), indices
).output(0)
coords = []
for dim_size in reversed(shape):View on GitHub (pinned to 7a34a03db6)