{"record":{"id":"739112d6614f58d2","repo":"keras-team/keras","slug":"if-using-weights-as-imagenet-with-include-t-739112","errorCode":null,"errorMessage":"If using `weights` as `\"imagenet\"` with `include_top` as true, `classes` should be 1000","messagePattern":"If using `weights` as `\"imagenet\"` with `include_top` as true, `classes` should be 1000","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/applications/nasnet.py","lineNumber":129,"sourceCode":"    Returns:\n        A model instance.\n    \"\"\"\n    if backend.image_data_format() == \"channels_first\":\n        raise ValueError(\n            \"NASNet does not support the `channels_first` image data \"\n            \"format. Switch to `channels_last` by editing your local \"\n            \"config file at ~/.keras/keras.json\"\n        )\n    if not (weights in {\"imagenet\", None} or file_utils.exists(weights)):\n        raise ValueError(\n            \"The `weights` argument should be either \"\n            \"`None` (random initialization), `imagenet` \"\n            \"(pre-training on ImageNet), \"\n            \"or the path to the weights file to be loaded.\"\n        )\n\n    if weights == \"imagenet\" and include_top and classes != 1000:\n        raise ValueError(\n            'If using `weights` as `\"imagenet\"` with `include_top` '\n            \"as true, `classes` should be 1000\"\n        )\n\n    if (\n        isinstance(input_shape, tuple)\n        and None in input_shape\n        and weights == \"imagenet\"\n    ):\n        raise ValueError(\n            \"When specifying the input shape of a NASNet and loading \"\n            \"`ImageNet` weights, the input_shape argument must be static\"\n            f\" (no None entries). Got: `input_shape={input_shape}`.\"\n        )\n\n    if default_size is None:\n        default_size = 331\n","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/applications/nasnet.py#L111-L147","documentation":"Error \"If using `weights` as `\"imagenet\"` with `include_top` as true, `classes` should be 1000\" thrown in keras-team/keras.","triggerScenarios":"Thrown at keras/src/applications/nasnet.py:129 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7a34a03db60bf60042242d6a556fc3be119046a5","analyzedAt":"2026-08-25T21:25:25.994Z","schemaVersion":2},"datasetVersion":"2026-08-26T02:17:13.382Z"}