keras-team/keras · error · ValueError

`label_mode` must be one of `"fine"`, `"coarse"`. Received:

Error message

`label_mode` must be one of `"fine"`, `"coarse"`. Received: label_mode={label_mode}.

What it means

Error "`label_mode` must be one of `"fine"`, `"coarse"`. Received: label_mode={label_mode}." thrown in keras-team/keras.

Source

Thrown at keras/src/datasets/cifar100.py:56

    **`x_test`**: `uint8` NumPy array of grayscale image data with shapes
      `(10000, 32, 32, 3)`, containing the test data. Pixel values range
      from 0 to 255.

    **`y_test`**: `uint8` NumPy array of labels (integers in range 0-99)
      with shape `(10000, 1)` for the test data.

    Example:

    ```python
    (x_train, y_train), (x_test, y_test) = keras.datasets.cifar100.load_data()
    assert x_train.shape == (50000, 32, 32, 3)
    assert x_test.shape == (10000, 32, 32, 3)
    assert y_train.shape == (50000, 1)
    assert y_test.shape == (10000, 1)
    ```
    """
    if label_mode not in ["fine", "coarse"]:
        raise ValueError(
            '`label_mode` must be one of `"fine"`, `"coarse"`. '
            f"Received: label_mode={label_mode}."
        )

    dirname = "cifar-100-python-target"
    origin = "https://www.cs.toronto.edu/~kriz/cifar-100-python.tar.gz"
    path = get_file(
        fname=dirname,
        origin=origin,
        extract=True,
        file_hash=(  # noqa: E501
            "85cd44d02ba6437773c5bbd22e183051d648de2e7d6b014e1ef29b855ba677a7"
        ),
    )

    path = os.path.join(path, "cifar-100-python")
    fpath = os.path.join(path, "train")
    x_train, y_train = load_batch(fpath, label_key=f"{label_mode}_labels")

View on GitHub (pinned to 7a34a03db6)

When it happens

Trigger: Thrown at keras/src/datasets/cifar100.py:56 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/2222e2018373f898. Report an issue: GitHub.