{"record":{"id":"2feeb99cde20744f","repo":"WZMIAOMIAO/deep-learning-for-image-processing","slug":"not-support-model-name","errorCode":null,"errorMessage":"not support model name: {}","messagePattern":"not support model name: (.+?)","errorType":"validation","errorClass":"KeyError","httpStatus":null,"severity":"error","filePath":"pytorch_classification/Test10_regnet/model.py","lineNumber":308,"sourceCode":"        stage_widths, stage_depths = np.unique(widths, return_counts=True)\n        stage_groups = [cfg['group_w'] for _ in range(num_stages)]\n        stage_widths, stage_groups = adjust_width_groups_comp(stage_widths, stage_groups)\n\n        info = []\n        for i in range(num_stages):\n            info.append(dict(out_c=stage_widths[i],\n                             depth=stage_depths[i],\n                             group_width=stage_groups[i],\n                             se_ratio=cfg[\"se_ratio\"]))\n\n        return info\n\n\ndef create_regnet(model_name=\"RegNetX_200MF\", num_classes=1000):\n    model_name = model_name.lower().replace(\"-\", \"_\")\n    if model_name not in model_cfgs.keys():\n        print(\"support model name: \\n{}\".format(\"\\n\".join(model_cfgs.keys())))\n        raise KeyError(\"not support model name: {}\".format(model_name))\n\n    model = RegNet(cfg=model_cfgs[model_name], num_classes=num_classes)\n    return model\n","sourceCodeStart":290,"sourceCodeEnd":312,"githubUrl":"https://github.com/WZMIAOMIAO/deep-learning-for-image-processing/blob/1ec3fe6f374fc9969973a61f819de25658595afa/pytorch_classification/Test10_regnet/model.py#L290-L312","documentation":"Factory function create_regnet looks up the lowercased, underscore-normalized model name in model_cfgs and raises KeyError (after printing the supported names) if absent. This catches invalid model_name strings before constructing a RegNet.","triggerScenarios":"Calling create_regnet('RegNetY-400MF') or a typo like 'regnet_x_400' when only specific X-variant keys exist in model_cfgs.","commonSituations":"Copy-pasted names from papers/blogs ('RegNetX400MF', hyphenated variants), requesting Y/F variants not defined in this repo.","solutions":["Use an exact supported key; the printed list from the KeyError message shows all valid names.","Normalize your name the same way the function does: lower() and replace('-','_') before checking.","Add a new entry to model_cfgs if you genuinely need an unsupported variant."],"exampleFix":"// before\nmodel = create_regnet(\"RegNetY-400MF\", num_classes=5)\n// after\nmodel = create_regnet(\"RegNetX-400MF\", num_classes=5)  # key present in model_cfgs","handlingStrategy":"validation","validationCode":"def safe_create_regnet(model_name, num_classes):\n    key = model_name.lower().replace(\"-\", \"_\")\n    from model import model_cfgs\n    if key not in model_cfgs:\n        raise KeyError(f\"{key} not supported. Valid: {sorted(model_cfgs)}\")\n    return create_regnet(model_name, num_classes)","typeGuard":"def is_supported_regnet(name: str, valid_keys) -> bool:\n    return name.lower().replace(\"-\", \"_\") in valid_keys","tryCatchPattern":"try:\n    model = create_regnet(args.model, num_classes=5)\nexcept KeyError as e:\n    print(f\"Unsupported model {e}; falling back to RegNetX_200MF\")\n    model = create_regnet(\"RegNetX_200MF\", num_classes=5)","preventionTips":["Copy model names only from the printed supported list","Normalize names with lower().replace('-','_') before lookup","Validate the CLI --model argument against model_cfgs.keys() at arg-parse time"],"tags":["pytorch","model-config","factory","keyerror"],"backgroundTag":"invalid-model-name","analyzedSha":"1ec3fe6f374fc9969973a61f819de25658595afa","analyzedAt":"2026-08-30T09:19:11.901Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}