keras-team/keras · error · TypeError

`output_size` must be an integer or (depth, height, width) t

Error message

`output_size` must be an integer or (depth, height, width) tuple. Received: {output_size} of type {type(output_size)}

What it means

Error "`output_size` must be an integer or (depth, height, width) tuple. Received: {output_size} of type {type(output_size)}" thrown in keras-team/keras.

Source

Thrown at keras/src/layers/pooling/adaptive_average_pooling3d.py:57

        - If `data_format="channels_first"`:
            `(batch_size, channels, output_depth, output_height, output_width)`

    Examples:
        >>> import numpy as np
        >>> input_vol = np.random.rand(1, 32, 32, 32, 3)
        >>> layer = AdaptiveAveragePooling3D(output_size=16)
        >>> output_vol = layer(input_vol)
        >>> output_vol.shape
        (1, 16, 16, 16, 3)
    """

    def __init__(self, output_size, data_format=None, **kwargs):
        if isinstance(output_size, int):
            output_size_tuple = (output_size, output_size, output_size)
        elif isinstance(output_size, (tuple, list)) and len(output_size) == 3:
            output_size_tuple = tuple(output_size)
        else:
            raise TypeError(
                f"`output_size` must be an integer or "
                f"(depth, 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_average_pooling3d.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/83a29203e70e1118. Report an issue: GitHub.