{"record":{"id":"08352ecca576e584","repo":"open-mmlab/mmdetection","slug":"the-item-in-out-indices-must-in-range-0-len-self","errorCode":null,"errorMessage":"the item in out_indices must in range(0, {len(self.layer_setting)}). But received {index}","messagePattern":"the item in out_indices must in range\\(0, (.+?)\\)\\. But received (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"mmdet/models/backbones/efficientnet.py","lineNumber":280,"sourceCode":"                 act_cfg=dict(type='Swish'),\n                 norm_eval=False,\n                 with_cp=False,\n                 init_cfg=[\n                     dict(type='Kaiming', layer='Conv2d'),\n                     dict(\n                         type='Constant',\n                         layer=['_BatchNorm', 'GroupNorm'],\n                         val=1)\n                 ]):\n        super(EfficientNet, self).__init__(init_cfg)\n        assert arch in self.arch_settings, \\\n            f'\"{arch}\" is not one of the arch_settings ' \\\n            f'({\", \".join(self.arch_settings.keys())})'\n        self.arch_setting = self.arch_settings[arch]\n        self.layer_setting = self.layer_settings[arch[:1]]\n        for index in out_indices:\n            if index not in range(0, len(self.layer_setting)):\n                raise ValueError('the item in out_indices must in '\n                                 f'range(0, {len(self.layer_setting)}). '\n                                 f'But received {index}')\n\n        if frozen_stages not in range(len(self.layer_setting) + 1):\n            raise ValueError('frozen_stages must be in range(0, '\n                             f'{len(self.layer_setting) + 1}). '\n                             f'But received {frozen_stages}')\n        self.drop_path_rate = drop_path_rate\n        self.out_indices = out_indices\n        self.frozen_stages = frozen_stages\n        self.conv_cfg = conv_cfg\n        self.norm_cfg = norm_cfg\n        self.act_cfg = act_cfg\n        self.norm_eval = norm_eval\n        self.with_cp = with_cp\n\n        self.layer_setting = model_scaling(self.layer_setting,\n                                           self.arch_setting)","sourceCodeStart":262,"sourceCodeEnd":298,"githubUrl":"https://github.com/open-mmlab/mmdetection/blob/cfd5d3a985b0249de009b67d04f37263e11cdf3d/mmdet/models/backbones/efficientnet.py#L262-L298","documentation":"EfficientNet validates each entry of out_indices against range(0, len(layer_setting)) for the chosen arch; an index outside the number of stages raises this ValueError. out_indices selects which stage feature maps the backbone returns.","triggerScenarios":"Setting out_indices=(1,2,3,4) on an EfficientNet arch whose stage list is shorter (e.g. b0 has stages 0..6 in mmdet but some archs fewer); using out_indices values copied from another backbone; negative indices (not allowed here, range starts at 0).","commonSituations":"Swapping backbone type in a neck config without adjusting out_indices; FPN configs assuming 5 outputs (0..4) on EfficientNet variants with different stage counts.","solutions":["Set out_indices to valid stage indices 0..num_stages-1 for the chosen arch (check layer_settings[arch[:1]] length in efficientnet.py)","Match the number of out_indices to the neck's in_channels list","Prefer explicit small indices like (1,2,3,4) only after confirming the arch supports them"],"exampleFix":"# before\nbackbone=dict(type='EfficientNet', arch='b0', out_indices=(1,2,3,4,5,6,7))\n# after\nbackbone=dict(type='EfficientNet', arch='b0', out_indices=(1,2,3,4))","handlingStrategy":"validation","validationCode":"n = len(backbone.layer_setting)\nassert all(isinstance(i, int) and 0 <= i < n for i in out_indices), f'out_indices must be in [0, {n})'","typeGuard":"def valid_out_indices(indices, n_stages: int) -> bool:\n    return all(isinstance(i, int) and 0 <= i < n_stages for i in indices)","tryCatchPattern":null,"preventionTips":["Match out_indices length to the neck in_channels","Check stage count per arch before swapping backbones","Use official EfficientNet configs as base"],"tags":["mmdet","efficientnet","out-indices","backbone","config"],"backgroundTag":null,"analyzedSha":"cfd5d3a985b0249de009b67d04f37263e11cdf3d","analyzedAt":"2026-08-27T20:54:20.183Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}