Missed TensorFlow World? Check out the recap. Learn more

tf.keras.layers.maximum

View source on GitHub

Functional interface to the Maximum layer that computes

Aliases:

  • tf.compat.v1.keras.layers.maximum
  • tf.compat.v2.keras.layers.maximum
tf.keras.layers.maximum(
    inputs,
    **kwargs
)

the maximum (element-wise) list of inputs.

For example:

input1 = tf.keras.layers.Input(shape=(16,))
x1 = tf.keras.layers.Dense(8, activation='relu')(input1) #shape=(None, 8)
input2 = tf.keras.layers.Input(shape=(32,))
x2 = tf.keras.layers.Dense(8, activation='relu')(input2) #shape=(None, 8)
max_inp=tf.keras.layers.maximum([x1,x2]) #shape=(None, 8)
out = tf.keras.layers.Dense(4)(max_inp)
model = tf.keras.models.Model(inputs=[input1, input2], outputs=out)

Arguments:

  • inputs: A list of input tensors (at least 2) of same shape.
  • **kwargs: Standard layer keyword arguments.

Returns:

A tensor (of same shape as input tensor) with the element-wise maximum of the inputs.

Raises:

  • ValueError: If input tensors are of different shape.