tensorflow/models · error · ValueError
More than one maxpool should be specified in SPP block
Error message
More than one maxpool should be specified in SPP block
What it means
Truthiness guard in SPP.__init__: the sizes argument (max-pooling kernel sizes for the Spatial Pyramid Pooling branches) is empty. An SPP layer with zero pooling branches is degenerate — it produces no multi-scale context — so construction is rejected. The message wording is itself buggy ('More than one' though the check requires at least one), but the remedy is the same: supply at least one pool size.
Solutions
- Provide a non-empty list of pool sizes, e.g. SPP(sizes=[1, 5, 9, 13])
- Check config plumbing if sizes arrives empty from YAML (a missing key defaulting to [])
- Omit the SPP layer entirely if no pooling branches are wanted
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at official/projects/yolo/modeling/layers/nn_blocks.py:1136 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/2a9725a9ebd54ad1.
Report an issue: GitHub.
Appendix: source
Thrown at official/projects/yolo/modeling/layers/nn_blocks.py:1136
def call(self, inputs, training=None):
# done this way to prevent confusion in the auto graph
if self._inverted:
return self._call_reversed(inputs, training=training)
else:
return self._call_regular(inputs, training=training)
class SPP(tf_keras.layers.Layer):
"""Spatial Pyramid Pooling.
A non-agregated SPP layer that uses Pooling.
"""
def __init__(self, sizes, **kwargs):
self._sizes = list(reversed(sizes))
if not sizes:
raise ValueError('More than one maxpool should be specified in SPP block')
super().__init__(**kwargs)
def build(self, input_shape):
maxpools = []
for size in self._sizes:
maxpools.append(
tf_keras.layers.MaxPool2D(
pool_size=(size, size),
strides=(1, 1),
padding='same',
data_format=None))
self._maxpools = maxpools
super().build(input_shape)
def call(self, inputs, training=None):
outputs = []
for maxpool in self._maxpools:
outputs.append(maxpool(inputs))View on GitHub (pinned to e006f5f0d5)