In python, classes may have the __call__
method, meaning that class instances are callable.
So, it's totally ok to call Activation(...)(...)
.
The first step creates an instance of Activation
, and the second calls that instance with some parameters.
It's exactly the same as doing:
activationLayer = Activation('relu')
outputTensor = activationLayer(inputTensor) #where inputTensor == X in your example
With this, you can also reuse the same layers with different input tensors:
activationLayer = Activation('relu')
out1 = activationLayer(X1)
out2 = activationLayer(X2)
This doesn't make a big difference with a standard activation layer, but it starts getting very interesting with certain trained layers.
Example: you want to use a standard trained VGG16 model to process two images and then join the images:
vgg16 = keras.applications.vgg16(......)
img1 = Input(imageShape1)
img2 = Input(imageShape2)
out1 = vgg16(img1) #a model is also a layer by inheritance
out2 = vgg16(img2)
... continue the model ....