open-mmlab/mmdetection · error · ValueError
the item in out_indices must in range(0, {len(self.layer_set
Error message
the item in out_indices must in range(0, {len(self.layer_setting)}). But received {index} What it means
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.
Source
Thrown at mmdet/models/backbones/efficientnet.py:280
act_cfg=dict(type='Swish'),
norm_eval=False,
with_cp=False,
init_cfg=[
dict(type='Kaiming', layer='Conv2d'),
dict(
type='Constant',
layer=['_BatchNorm', 'GroupNorm'],
val=1)
]):
super(EfficientNet, self).__init__(init_cfg)
assert arch in self.arch_settings, \
f'"{arch}" is not one of the arch_settings ' \
f'({", ".join(self.arch_settings.keys())})'
self.arch_setting = self.arch_settings[arch]
self.layer_setting = self.layer_settings[arch[:1]]
for index in out_indices:
if index not in range(0, len(self.layer_setting)):
raise ValueError('the item in out_indices must in '
f'range(0, {len(self.layer_setting)}). '
f'But received {index}')
if frozen_stages not in range(len(self.layer_setting) + 1):
raise ValueError('frozen_stages must be in range(0, '
f'{len(self.layer_setting) + 1}). '
f'But received {frozen_stages}')
self.drop_path_rate = drop_path_rate
self.out_indices = out_indices
self.frozen_stages = frozen_stages
self.conv_cfg = conv_cfg
self.norm_cfg = norm_cfg
self.act_cfg = act_cfg
self.norm_eval = norm_eval
self.with_cp = with_cp
self.layer_setting = model_scaling(self.layer_setting,
self.arch_setting)View on GitHub (pinned to cfd5d3a985)
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
Example fix
# before backbone=dict(type='EfficientNet', arch='b0', out_indices=(1,2,3,4,5,6,7)) # after backbone=dict(type='EfficientNet', arch='b0', out_indices=(1,2,3,4))
Defensive patterns
Strategy: validation
Validate before calling
n = len(backbone.layer_setting)
assert all(isinstance(i, int) and 0 <= i < n for i in out_indices), f'out_indices must be in [0, {n})' Type guard
def valid_out_indices(indices, n_stages: int) -> bool:
return all(isinstance(i, int) and 0 <= i < n_stages for i in indices) Prevention
- Match out_indices length to the neck in_channels
- Check stage count per arch before swapping backbones
- Use official EfficientNet configs as base
When it happens
Trigger: 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).
Common situations: 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.
Related errors
- frozen_stages must be in range(0, {len(self.layer_setting) +
- frozen_stages must be in range(-1, len(arch_setting) + 1). B
- frozen_stages must be in range(-1, len(arch_setting) + 1). B
- invalid depth {depth} for darknet
- out_indices must be a subset of range(0, 8). But received {o
AI-assisted analysis of open-mmlab/mmdetection@cfd5d3a985 (2026-08-27).
Data as JSON: /api/errors/08352ecca576e584.
Report an issue: GitHub.