keras-team/keras · error · ValueError
Illegal None dimension in {x} with shape {x.shape}
Error message
Illegal None dimension in {x} with shape {x.shape} What it means
Error "Illegal None dimension in {x} with shape {x.shape}" thrown in keras-team/keras.
Source
Thrown at keras/src/backend/jax/export.py:159
def _to_polymorphic_shape(self, struct, allow_none=True):
if allow_none:
# Generates unique names: a, b, ... z, aa, ab, ... az, ba, ... zz
# for unknown non-batch dims. Defined here to be scope per endpoint.
dim_names = itertools.chain(
string.ascii_lowercase,
itertools.starmap(
lambda a, b: a + b,
itertools.product(string.ascii_lowercase, repeat=2),
),
)
def convert_shape(x):
poly_shape = []
for index, dim in enumerate(list(x.shape)):
if dim is not None:
poly_shape.append(str(dim))
elif not allow_none:
raise ValueError(
f"Illegal None dimension in {x} with shape {x.shape}"
)
elif index == 0:
poly_shape.append("batch")
else:
poly_shape.append(next(dim_names))
return f"({', '.join(poly_shape)})"
return tree.map_structure(convert_shape, struct)
def _check_device_compatible(self):
from jax import default_backend as jax_device
if (
jax_device() == "gpu"
and len(tf.config.list_physical_devices("GPU")) == 0
):
warnings.warn(View on GitHub (pinned to 7a34a03db6)
When it happens
Trigger: Thrown at keras/src/backend/jax/export.py:159 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/7316c0b934cd3a33.
Report an issue: GitHub.