tensorflow/models · error · ValueError
The resnet_depth should be in
Error message
The resnet_depth should be in [%s]. Not a valid resnet_depth:
What it means
Validation in the ResNet constructor: resnet_depth is not a key of the hardcoded depth-to-block-layout table (18, 34, 50, 101, 152, 200, ...), so the number of residual blocks per stage cannot be determined. The message lists the valid depths it computed from that table.
Solutions
- Use one of the supported depths, e.g. resnet_depth=50 or 101
- Correct the resnet_depth value in the backbone config
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at official/legacy/detection/modeling/architecture/resnet.py:94 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of tensorflow/models@e006f5f0d5 (2026-08-24).
Data as JSON: /api/errors/10c203f8a8253413.
Report an issue: GitHub.
Appendix: source
Thrown at official/legacy/detection/modeling/architecture/resnet.py:94
},
101: {
'block': self.bottleneck_block,
'layers': [3, 4, 23, 3]
},
152: {
'block': self.bottleneck_block,
'layers': [3, 8, 36, 3]
},
200: {
'block': self.bottleneck_block,
'layers': [3, 24, 36, 3]
}
}
if resnet_depth not in model_params:
valid_resnet_depths = ', '.join(
[str(depth) for depth in sorted(model_params.keys())])
raise ValueError(
'The resnet_depth should be in [%s]. Not a valid resnet_depth:' %
(valid_resnet_depths), self._resnet_depth)
params = model_params[resnet_depth]
self._resnet_fn = self.resnet_v1_generator(params['block'],
params['layers'])
def __call__(self, inputs, is_training=None):
"""Returns the ResNet model for a given size and number of output classes.
Args:
inputs: a `Tesnor` with shape [batch_size, height, width, 3] representing
a batch of images.
is_training: `bool` if True, the model is in training mode.
Returns:
a `dict` containing `int` keys for continuous feature levels [2, 3, 4, 5].
The values are corresponding feature hierarchy in ResNet with shape
[batch_size, height_l, width_l, num_filters].View on GitHub (pinned to e006f5f0d5)