applies an activation function to an output args activation activation function it could be a callable or the name of an activation from the keras activations namespace kwargs base layer keyword arguments such as name and dtype example layer keras layers activation relu layer3 0 1 0 0 0 2 0 0 0 0 0 0 0 2 0 layer keras layers activationkeras activations relu layer3 0 1 0 0 0 2 0 0 0 0 0 0 0 2 0 applies an activation function to an output args activation activation function it could be a callable or the name of an activation from the keras activations namespace kwargs base layer keyword arguments such as name and dtype example layer keras layers activation relu layer 3 0 1 0 0 0 2 0 0 0 0 0 0 0 2 0 layer keras layers activation keras activations relu layer 3 0 1 0 0 0 2 0 0 0 0 0 0 0 2 0
from keras import activations
from keras.api_export import keras_export
from keras.layers.layer import Layer


@keras_export("keras.layers.Activation")
class Activation(Layer):
    

    def __init__(self, activation, **kwargs):
        super().__init__(**kwargs)
        self.supports_masking = True
        self.activation = activations.get(activation)

    def call(self, inputs):
        return self.activation(inputs)

    def compute_output_shape(self, input_shape):
        return input_shape

    def get_config(self):
        config = {"activation": activations.serialize(self.activation)}
        base_config = super().get_config()
        return {**base_config, **config}