tf.keras.layers.Concatenate  |  TensorFlow v2.16.1 (original) (raw)

tf.keras.layers.Concatenate

Stay organized with collections Save and categorize content based on your preferences.

Concatenates a list of inputs.

Inherits From: Layer, Operation

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

Used in the notebooks

Used in the guide Used in the tutorials
Migrate `tf.feature_column`s to Keras preprocessing layers Migrate from TPU embedding_columns to TPUEmbedding layer Load CSV data pix2pix: Image-to-image translation with a conditional GAN Image segmentation Networks TFX Keras Component Tutorial

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])

Args
axis Axis along which to concatenate.
**kwargs Standard layer keyword arguments.
Returns
A tensor, the concatenation of the inputs alongside axis axis.
Attributes
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

@classmethod from_config( config )

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

symbolic_call(
    *args, **kwargs
)