Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

Keras · Class

layers.Concatenate

Keras Concatenate joins a list of tensors along one chosen axis. Inputs must have matching shapes on every other axis, and the default join axis is the last one.

How it works

Concatenate accepts a list of tensors and joins them along the selected axis. Every dimension other than that axis must match, and the resulting tensor has the combined size along the chosen axis.

Syntax

keras.layers.Concatenate(axis=-1, **kwargs)

Parameters

NameTypeDescription
axisintAxis along which to concatenate.
**kwargsdictStandard layer keyword arguments.

Returns

A tensor, the concatenation of the inputs alongside axis axis.

Key points

  • The layer merges multiple input tensors into one output tensor.
  • Its constructor defaults to the last axis and also accepts standard layer keyword arguments.
  • The axis argument selects the dimension where input tensors are joined.
  • The result is one tensor rather than a list of separately preserved inputs.
  • The output contains the values from every supplied input in concatenated order.

Common mistakes

  • Inputs must match in every dimension except the axis being joined.

Example: Concatenate tensors along an axis

import numpy as np
import keras

x = np.arange(20).reshape(2, 2, 5)
y = np.arange(20, 30).reshape(2, 1, 5)
result = keras.layers.Concatenate(axis=1)([x, y])
print(result.shape)  # (2, 3, 5)

Concatenates two tensors along their second axis while preserving the other dimensions.

When to use it

Feature fusion

Combining parallel branches in a neural network

Representation joining

Merging embeddings or encoded representations

Structured tensor assembly

Joining spatial or sequence tensors along a compatible dimension

Interview questions

QWhat does Concatenate do, and what shape constraint does it impose?

It joins a list of tensors into one tensor along the configured axis. The inputs must have identical shapes everywhere except on that axis.

Follow-up: What happens to the selected dimension? Its size becomes the sum of that dimension across all input tensors.

QWhat is the default axis?

The default axis is -1, so concatenation occurs on the last dimension unless another axis is supplied. For example, axis=1 joins the tensors along their second dimension.

Follow-up: Why might axis=-1 be convenient? It commonly combines feature dimensions while leaving batch and earlier structural dimensions unchanged.

QHow is Concatenate invoked?

The layer is called with a list of tensors, such as keras.layers.Concatenate()([x1, x2]). It returns a single tensor representing their concatenation.

Follow-up: How can it be used in a model? Apply it to outputs from parallel layers before passing the merged tensor to a subsequent layer.

  • keras.layers.Add
  • keras.layers.Average
  • keras.layers.Multiply
  • keras.layers.Cropping1D
  • keras.layers.Cropping2D

Source: Concatenate layer. Checked 2026-10-15.