tf.keras.layers.Lambda

Wraps arbitrary expressions as a Layer object.

Inherits From: Layer

Used in the notebooks

Used in the tutorials

The Lambda layer exists so that arbitrary TensorFlow functions can be used when constructing Sequential and Functional API models. Lambda layers are best suited for simple operations or quick experimentation. For more advanced use cases, follow this guide for subclassing tf.keras.layers.Layer.

The main reason to subclass tf.keras.layers.Layer instead of using a Lambda layer is saving and inspecting a Model.