Keras功能API的语法 [英] Syntax of Keras Functional API

查看:87
本文介绍了Keras功能API的语法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对keras函数式API的语法如何工作感到困惑。它对于定义复杂的多输入和输出模型非常有用。但语法对我来说有点令人费解。

  new_layer = Conv2d(...)(old_layer)

据我所知Conv2d是一个 class 。 Conv2d()()语法在 python 中如何工作?

解决方案

Conv2d(...)。(X)相当于:

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

其中图层()相当于 layer .__ call __(self,....)


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,....).

这篇关于Keras功能API的语法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆