keras-team/keras · error · ValueError

When specifying the input shape of a NASNet and loading `Ima

Error message

When specifying the input shape of a NASNet and loading `ImageNet` weights, the input_shape argument must be static (no None entries). Got: `input_shape={input_shape}`.

What it means

Error "When specifying the input shape of a NASNet and loading `ImageNet` weights, the input_shape argument must be static (no None entries). Got: `input_shape={input_shape}`." thrown in keras-team/keras.

Source

Thrown at keras/src/applications/nasnet.py:139

        raise ValueError(
            "The `weights` argument should be either "
            "`None` (random initialization), `imagenet` "
            "(pre-training on ImageNet), "
            "or the path to the weights file to be loaded."
        )

    if weights == "imagenet" and include_top and classes != 1000:
        raise ValueError(
            'If using `weights` as `"imagenet"` with `include_top` '
            "as true, `classes` should be 1000"
        )

    if (
        isinstance(input_shape, tuple)
        and None in input_shape
        and weights == "imagenet"
    ):
        raise ValueError(
            "When specifying the input shape of a NASNet and loading "
            "`ImageNet` weights, the input_shape argument must be static"
            f" (no None entries). Got: `input_shape={input_shape}`."
        )

    if default_size is None:
        default_size = 331

    # Determine proper input shape and default size.
    input_shape = imagenet_utils.obtain_input_shape(
        input_shape,
        default_size=default_size,
        min_size=32,
        data_format=backend.image_data_format(),
        require_flatten=include_top,
        weights=weights,
    )

View on GitHub (pinned to 7a34a03db6)

When it happens

Trigger: Thrown at keras/src/applications/nasnet.py:139 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/0908b2effbe2fb94. Report an issue: GitHub.