keras-team/keras · error · ValueError

Invalid `image_data_format` configuration. Expected one of {

Error message

Invalid `image_data_format` configuration. Expected one of {'channels_last', 'channels_first'}. Received: image_data_format={_image_data_format}

What it means

Error "Invalid `image_data_format` configuration. Expected one of {'channels_last', 'channels_first'}. Received: image_data_format={_image_data_format}" thrown in keras-team/keras.

Source

Thrown at keras/src/backend/config.py:320

        _config = {}
    _floatx = _config.get("floatx", floatx())
    if _floatx not in {"float16", "float32", "float64"}:
        raise ValueError(
            "Invalid `floatx` configuration. "
            "Expected one of {'float16', 'float32', 'float64'}. "
            f"Received: floatx={_floatx}"
        )
    _epsilon = _config.get("epsilon", epsilon())
    if not isinstance(_epsilon, float):
        raise ValueError(
            "Invalid `epsilon` configuration. "
            "Expected a float. "
            f"Received: epsilon={_epsilon}"
        )
    _backend = _config.get("backend", _BACKEND)
    _image_data_format = _config.get("image_data_format", image_data_format())
    if _image_data_format not in {"channels_last", "channels_first"}:
        raise ValueError(
            "Invalid `image_data_format` configuration. "
            "Expected one of {'channels_last', 'channels_first'}. "
            f"Received: image_data_format={_image_data_format}"
        )
    _nnx_enabled_config = _config.get("nnx_enabled", _NNX_ENABLED)

    # Apply basic configs that don't cause circular import
    set_floatx(_floatx)
    _NNX_ENABLED = _nnx_enabled_config
    set_epsilon(_epsilon)
    set_image_data_format(_image_data_format)
    _BACKEND = _backend

# Save config file, if possible.
if not os.path.exists(_KERAS_DIR):
    try:
        os.makedirs(_KERAS_DIR)
    except OSError:

View on GitHub (pinned to 7a34a03db6)

When it happens

Trigger: Thrown at keras/src/backend/config.py:320 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/82b8f5537b0d827f. Report an issue: GitHub.