tensorflow/models · error · ValueError
the structure of `anchor_sizes` must be a tuple, list, or di
Error message
the structure of `anchor_sizes` must be a tuple, list, or dict, given {} What it means
Error "the structure of `anchor_sizes` must be a tuple, list, or dict, given {}" thrown in tensorflow/models.
Source
Thrown at official/vision/ops/anchor_generator.py:179
self.anchor_generators.append(
_SingleAnchorGenerator(anchor_size, scale_list, ar_list, stride,
clip_boxes))
def __call__(self, image_size):
anchor_generators = tf.nest.flatten(self.anchor_generators)
results = [anchor_gen(image_size) for anchor_gen in anchor_generators]
return tf.nest.pack_sequence_as(self.anchor_generators, results)
def maybe_map_structure_for_anchor(params, anchor_sizes):
"""broadcast the params to match anchor_sizes."""
if all(isinstance(param, (int, float)) for param in params):
if isinstance(anchor_sizes, (tuple, list)):
return [params] * len(anchor_sizes)
elif isinstance(anchor_sizes, dict):
return tf.nest.map_structure(lambda _: params, anchor_sizes)
else:
raise ValueError("the structure of `anchor_sizes` must be a tuple, "
"list, or dict, given {}".format(anchor_sizes))
else:
return params
View on GitHub (pinned to e006f5f0d5)
Solutions
- Pass anchor_sizes as a tuple, list, or dict of level -> sizes.
- Wrap a single size in a list or map it per feature level in a dict.
When it happens
Trigger: Thrown at official/vision/ops/anchor_generator.py:179 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/da9c7f16f6b71d58.
Report an issue: GitHub.