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 ?


Conv2d(...).(X) is equivalent to:

layer = Conv2d(...)
X = layer(X)

where layer() is equivalent to layer.__call__(self,....) .


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.

链接地址: http://www.djcxy.com/p/70608.html

上一篇: 单个或多个表

下一篇: Keras功能API的语法