TensorFlow BasicLSTMCell实现中的'call'和'__call__'有什么区别? [英] What is difference between 'call' and '__call__' in TensorFlow BasicLSTMCell implementation?

查看:599
本文介绍了TensorFlow BasicLSTMCell实现中的'call'和'__call__'有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究Tensorflow BasicLSTMCell 发现该类中有两种类似的方法:__call__call.两种方法具有相同的参数,文档中没有说明不同之处.引用源代码不给我任何线索.但是我猜想__call__方法是从某个地方继承的,而call会覆盖__call__.如果是这种情况,为什么不直接在源代码中使用__call__而不是call?

I am studying Tensorflow BasicLSTMCell while I found that there are two similar methods within the class: __call__ and call. The two methods has the same parameters and the documentation does not say the difference. Refering the source code does not give me any clue of this. But I am guessing that the the __call__ method is inherited from somewhere, and call overrides __call__. If this is the case, why not just use __call__ instead of call in the source code?

推荐答案

我在研究 RNNCell 时遇到了类似的问题.

I ran into similar problem when studying RNNCell.

__ call __ 是在 base_layer.py 的类 Layer 中包装的,在 call 中,应用pre-和后处理步骤".

It is in Class Layer in base_layer.py that __call__ wraps in call, "applying pre- and post-processing steps".

这篇关于TensorFlow BasicLSTMCell实现中的'call'和'__call__'有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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