{"record":{"id":"c1d14e06de0748c4","repo":"keras-team/keras","slug":"a-concatenate-layer-should-be-called-on-a-list-o","errorCode":null,"errorMessage":"A `Concatenate` layer should be called on a list of at least 1 input. Received: input_shape={input_shape}","messagePattern":"A `Concatenate` layer should be called on a list of at least 1 input\\. Received: input_shape=(.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/layers/merging/concatenate.py","lineNumber":47,"sourceCode":"        axis: Axis along which to concatenate.\n        **kwargs: Standard layer keyword arguments.\n\n    Returns:\n        A tensor, the concatenation of the inputs alongside axis `axis`.\n    \"\"\"\n\n    def __init__(self, axis=-1, **kwargs):\n        super().__init__(**kwargs)\n        self.axis = axis\n        self.supports_masking = True\n        self._reshape_required = False\n\n    def build(self, input_shape):\n        # Used purely for shape validation.\n        if len(input_shape) < 1 or not isinstance(\n            input_shape[0], (tuple, list)\n        ):\n            raise ValueError(\n                \"A `Concatenate` layer should be called on a list of \"\n                f\"at least 1 input. Received: input_shape={input_shape}\"\n            )\n        if all(shape is None for shape in input_shape):\n            return\n\n        reduced_inputs_shapes = [list(shape) for shape in input_shape]\n        reduced_inputs_shapes_copy = copy.copy(reduced_inputs_shapes)\n        shape_set = set()\n        for i in range(len(reduced_inputs_shapes_copy)):\n            # Convert self.axis to positive axis for each input\n            # in case self.axis is a negative number\n            concat_axis = self.axis % len(reduced_inputs_shapes_copy[i])\n            #  Skip batch axis.\n            for axis, axis_value in enumerate(\n                reduced_inputs_shapes_copy, start=1\n            ):\n                # Remove squeezable axes (axes with value of 1)","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/layers/merging/concatenate.py#L29-L65","documentation":"Concatenate.build validates that input_shape is a list containing at least one shape (each itself a tuple/list). This catches calls where the layer got a single tensor's shape or an empty list, which are invalid for concatenation.","triggerScenarios":"Calling Concatenate()(x) with one tensor; Concatenate()([]); a Functional node wiring only one branch into the concat layer.","commonSituations":"Conditionally adding branches so that sometimes only one reaches the concat; incorrect list nesting.","solutions":["Pass a list of two or more tensors: Concatenate()([a, b])","Ensure all code paths deliver at least two tensors to the concat layer","Check that upstream conditionals/filters do not reduce the input list to one element"],"exampleFix":"# before\nout = layers.Concatenate()(x)\n\n# after\nout = layers.Concatenate()([x, y])","handlingStrategy":"validation","validationCode":"assert isinstance(inputs, (list, tuple)) and len(inputs) >= 2, 'Concatenate needs a list of >= 2 tensors'","typeGuard":"def is_concat_input(inputs) -> bool:\n    return isinstance(inputs, (list, tuple)) and len(inputs) >= 2","tryCatchPattern":null,"preventionTips":["Use explicit list literals at concat sites","Ensure conditional branches always contribute at least two tensors"],"tags":["keras","concatenate","input-format"],"backgroundTag":"wrong-argument-structure","analyzedSha":"7a34a03db60bf60042242d6a556fc3be119046a5","analyzedAt":"2026-08-25T21:25:25.994Z","schemaVersion":2},"datasetVersion":"2026-08-26T02:17:13.382Z"}