{"record":{"id":"c7fc72f0820c69d3","repo":"keras-team/keras","slug":"output-size-must-be-an-integer-or-tuple-of-1-int","errorCode":null,"errorMessage":"`output_size` must be an integer or tuple of 1 integer. Received: {output_size} of type {type(output_size)}","messagePattern":"`output_size` must be an integer or tuple of 1 integer\\. Received: (.+?) of type (.+?)","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"keras/src/layers/pooling/adaptive_average_pooling1d.py","lineNumber":60,"sourceCode":"        >>> input_seq = np.random.rand(1, 64, 3)\n        >>> layer = AdaptiveAveragePooling1D(output_size=32)\n        >>> output_seq = layer(input_seq)\n        >>> output_seq.shape\n        (1, 32, 3)\n    \"\"\"\n\n    def __init__(self, output_size, data_format=None, **kwargs):\n        if isinstance(output_size, int):\n            output_size = (output_size,)\n        elif isinstance(output_size, (tuple, list)):\n            if len(output_size) != 1:\n                raise ValueError(\n                    f\"For 1D input, `output_size` tuple must have length 1. \"\n                    f\"Received: {output_size}\"\n                )\n            output_size = tuple(output_size)\n        else:\n            raise TypeError(\n                f\"`output_size` must be an integer or tuple of 1 integer. \"\n                f\"Received: {output_size} of type {type(output_size)}\"\n            )\n\n        super().__init__(output_size, data_format, **kwargs)\n","sourceCodeStart":42,"sourceCodeEnd":66,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/layers/pooling/adaptive_average_pooling1d.py#L42-L66","documentation":"AdaptiveAveragePooling1D's output_size fell through the int and tuple/list isinstance branches, meaning it is neither an integer nor a 1-element tuple — e.g. None, a float, a string, or a numpy array. The constructor normalizes output_size to a canonical 1-tuple and cannot proceed with other types.","triggerScenarios":"Thrown at keras/src/layers/pooling/adaptive_average_pooling1d.py:60 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass an int such as 32 or a tuple (32,)","Cast numpy scalars with int() before constructing the layer"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7a34a03db60bf60042242d6a556fc3be119046a5","analyzedAt":"2026-08-25T21:25:25.994Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}