{"record":{"id":"175aa4de0109c46c","repo":"open-mmlab/mmdetection","slug":"expect-arch-to-be-either-a-string-or-a-dict-got","errorCode":null,"errorMessage":"Expect \"arch\" to be either a string or a dict, got {type(arch)}","messagePattern":"Expect \"arch\" to be either a string or a dict, got (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"mmdet/models/backbones/regnet.py","lineNumber":121,"sourceCode":"                 norm_cfg=dict(type='BN', requires_grad=True),\n                 norm_eval=True,\n                 dcn=None,\n                 stage_with_dcn=(False, False, False, False),\n                 plugins=None,\n                 with_cp=False,\n                 zero_init_residual=True,\n                 pretrained=None,\n                 init_cfg=None):\n        super(ResNet, self).__init__(init_cfg)\n\n        # Generate RegNet parameters first\n        if isinstance(arch, str):\n            assert arch in self.arch_settings, \\\n                f'\"arch\": \"{arch}\" is not one of the' \\\n                ' arch_settings'\n            arch = self.arch_settings[arch]\n        elif not isinstance(arch, dict):\n            raise ValueError('Expect \"arch\" to be either a string '\n                             f'or a dict, got {type(arch)}')\n\n        widths, num_stages = self.generate_regnet(\n            arch['w0'],\n            arch['wa'],\n            arch['wm'],\n            arch['depth'],\n        )\n        # Convert to per stage format\n        stage_widths, stage_blocks = self.get_stages_from_blocks(widths)\n        # Generate group widths and bot muls\n        group_widths = [arch['group_w'] for _ in range(num_stages)]\n        self.bottleneck_ratio = [arch['bot_mul'] for _ in range(num_stages)]\n        # Adjust the compatibility of stage_widths and group_widths\n        stage_widths, group_widths = self.adjust_width_group(\n            stage_widths, self.bottleneck_ratio, group_widths)\n\n        # Group params by stage","sourceCodeStart":103,"sourceCodeEnd":139,"githubUrl":"https://github.com/open-mmlab/mmdetection/blob/cfd5d3a985b0249de009b67d04f37263e11cdf3d/mmdet/models/backbones/regnet.py#L103-L139","documentation":"RegNet.__init__ requires `arch` to be either a string key present in arch_settings ('regnetx_400mf', 'regnetx_800mf', etc.) or a dict containing w0, wa, wm, group_w, depth. Any other type (e.g. a list) raises ValueError. An unknown string instead fails the preceding assert.","triggerScenarios":"RegNet(arch=['regnetx_400mf']) (list instead of str); RegNet(arch='regnetx_1.6gf') with a typo'd/unsupported arch name (hits assert); RegNet(arch=dict(missing keys)).","commonSituations":"Typos in arch names in configs; loading arch from YAML/JSON where it parses as a non-str type; using a newer arch name unsupported by the installed mmdet version.","solutions":["Use an exact arch_settings key, e.g. arch='regnetx_800mf'","Or pass a full dict with keys w0, wa, wm, group_w, depth","Check self.arch_settings in mmdet/models/backbones/regnet.py for supported names in your version"],"exampleFix":"// before\nbackbone=dict(type='RegNet', arch='regnetx-400mf')\n// after\nbackbone=dict(type='RegNet', arch='regnetx_400mf')","handlingStrategy":"validation","validationCode":"from mmdet.models.backbones.regnet import RegNet\\nassert arch in RegNet.arch_settings or (isinstance(arch, dict) and {'w0','wa','wm','group_w','depth'} <= set(arch))","typeGuard":"def is_valid_regnet_arch(a):\\n    return (isinstance(a, str) and a in RegNet.arch_settings) or (isinstance(a, dict) and {'w0','wa','wm','group_w','depth'} <= set(a))","tryCatchPattern":null,"preventionTips":["Look up supported arch names in the installed mmdet source","Lint config keys against arch_settings before training runs"],"tags":["mmdet","regnet","arch-settings","config","validation"],"backgroundTag":"invalid-config-value","analyzedSha":"cfd5d3a985b0249de009b67d04f37263e11cdf3d","analyzedAt":"2026-08-27T20:54:20.183Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}