Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Syntax of Keras Functional API

I am kinda confused on how the syntax in the keras functional API works. Its really useful to define complex multi input and output models. But the syntax is kinda puzzling for me.

new_layer = Conv2d(...)(old_layer)

as far as I know the Conv2d is a class. How does Conv2d()() syntax work in python?

like image 817
Abhijit Balaji Avatar asked Mar 07 '23 19:03

Abhijit Balaji


1 Answers

Every object in python that implements a __call__() method can be called directly (you can take a look at this question or this tutorial). All keras layers implement this function (see source) and the implementation is supposed to return output of the layer given the input tensor.

like image 173
S.Mohsen sh Avatar answered Mar 14 '23 22:03

S.Mohsen sh