keras-team/keras · error · TypeError
`output_size` must be an integer or (height, width) tuple. R
Error message
`output_size` must be an integer or (height, width) tuple. Received: {output_size} of type {type(output_size)} What it means
Error "`output_size` must be an integer or (height, width) tuple. Received: {output_size} of type {type(output_size)}" thrown in keras-team/keras.
Source
Thrown at keras/src/layers/pooling/adaptive_max_pooling2d.py:57
- If `data_format="channels_first"`:
`(batch_size, channels, output_height, output_width)`
Examples:
>>> import numpy as np
>>> input_img = np.random.rand(1, 64, 64, 3)
>>> layer = AdaptiveMaxPooling2D(output_size=32)
>>> output_img = layer(input_img)
>>> output_img.shape
(1, 32, 32, 3)
"""
def __init__(self, output_size, data_format=None, **kwargs):
if isinstance(output_size, int):
output_size_tuple = (output_size, output_size)
elif isinstance(output_size, (tuple, list)) and len(output_size) == 2:
output_size_tuple = tuple(output_size)
else:
raise TypeError(
f"`output_size` must be an integer or (height, width) tuple. "
f"Received: {output_size} of type {type(output_size)}"
)
super().__init__(output_size_tuple, data_format, **kwargs)
View on GitHub (pinned to 7a34a03db6)
When it happens
Trigger: Thrown at keras/src/layers/pooling/adaptive_max_pooling2d.py:57 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of keras-team/keras@7a34a03db6 (2026-08-25).
Data as JSON: /api/errors/12af564bfb576d3a.
Report an issue: GitHub.