{"record":{"id":"0a4e1ec1e15f5db8","repo":"keras-team/keras","slug":"the-weights-argument-should-be-either-none-ra-0a4e1e","errorCode":null,"errorMessage":"The `weights` argument should be either `None` (random initialization), `imagenet` (pre-training on ImageNet), or the path to the weights file to be loaded.  Received weights={weights}","messagePattern":"The `weights` argument should be either `None` \\(random initialization\\), `imagenet` \\(pre-training on ImageNet\\), or the path to the weights file to be loaded\\.  Received weights=(.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/applications/mobilenet_v3.py","lineNumber":171,"sourceCode":"def MobileNetV3(\n    stack_fn,\n    last_point_ch,\n    input_shape=None,\n    alpha=1.0,\n    model_type=\"large\",\n    minimalistic=False,\n    include_top=True,\n    weights=\"imagenet\",\n    input_tensor=None,\n    classes=1000,\n    pooling=None,\n    dropout_rate=0.2,\n    classifier_activation=\"softmax\",\n    include_preprocessing=True,\n    name=None,\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            f\"Received weights={weights}\"\n        )\n\n    if weights == \"imagenet\" and include_top and classes != 1000:\n        raise ValueError(\n            'If using `weights=\"imagenet\"` with `include_top` '\n            \"as true, `classes` should be 1000.  \"\n            f\"Received classes={classes}\"\n        )\n\n    # Determine proper input shape and default size.\n    # If both input_shape and input_tensor are used, they should match\n    if input_shape is not None and input_tensor is not None:\n        try:","sourceCodeStart":153,"sourceCodeEnd":189,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/applications/mobilenet_v3.py#L153-L189","documentation":"Error \"The `weights` argument should be either `None` (random initialization), `imagenet` (pre-training on ImageNet), or the path to the weights file to be loaded.  Received weights={weights}\" thrown in keras-team/keras.","triggerScenarios":"Thrown at keras/src/applications/mobilenet_v3.py:171 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"}