keras-team/keras · error · TypeError

Argument `axes` must be a dict with integer keys. Received:

Error message

Argument `axes` must be a dict with integer keys. Received: axes={axes}

What it means

Error "Argument `axes` must be a dict with integer keys. Received: axes={axes}" thrown in keras-team/keras.

Source

Thrown at keras/src/layers/input_spec.py:81

        self.dtype = (
            backend.standardize_dtype(dtype) if dtype is not None else None
        )
        if shape is not None:
            self.shape = backend.standardize_shape(shape)
            self.ndim = len(shape)
        else:
            self.ndim = ndim
            self.shape = None
        self.max_ndim = max_ndim
        self.min_ndim = min_ndim
        self.name = name
        self.optional = optional
        self.allow_last_axis_squeeze = allow_last_axis_squeeze
        try:
            axes = axes or {}
            self.axes = {int(k): axes[k] for k in axes}
        except (ValueError, TypeError):
            raise TypeError(
                "Argument `axes` must be a dict with integer keys. "
                f"Received: axes={axes}"
            )

        if self.axes and (self.ndim is not None or self.max_ndim is not None):
            max_dim = (self.ndim if self.ndim else self.max_ndim) - 1
            max_axis = max(self.axes)
            if max_axis > max_dim:
                raise ValueError(
                    "Axis {} is greater than the maximum "
                    "allowed value: {}".format(max_axis, max_dim)
                )

    def __repr__(self):
        spec = [
            (f"dtype={str(self.dtype)}") if self.dtype else "",
            (f"shape={str(self.shape)}") if self.shape else "",
            (f"ndim={str(self.ndim)}") if self.ndim else "",

View on GitHub (pinned to 7a34a03db6)

When it happens

Trigger: Thrown at keras/src/layers/input_spec.py:81 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/913ead2db94d444f. Report an issue: GitHub.