tf.keras.layers.Concatenate

Concatenates a list of inputs.

Inherits From: Layer, Operation

Used in the notebooks

Used in the guide Used in the tutorials

It takes as input a list of tensors, all of the same shape except for the concatenation axis, and returns a single tensor that is the concatenation of all inputs.

Examples:

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

Usage in a Keras model:

x1 = keras.layers.Dense(8)(np.arange(10).reshape(5, 2))
x2 = keras.layers.Dense(8)(np.arange(10, 20).reshape(5, 2))
y = keras.layers.Concatenate()([x1, x2])

axis Axis along which to concatenate.
**kwargs Standard layer keyword arguments.

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

input Retrieves the input tensor(s) of a symbolic operation.

Only returns the tensor(s) corresponding to the first time the operation was called.

output Retrieves the output tensor(s) of a layer.

Only returns the tensor(s) corresponding to the first time the operation was called.

Methods

from_config

View source

Creates a layer from its config.

This method is the reverse of get_config, capable of instantiating the same layer from the config dictionary. It does not handle layer connectivity (handled by Network), nor weights (handled by set_weights).

Args
config A Python dictionary, typically the output of get_config.

Returns
A layer instance.

symbolic_call

View source