What does this syntax mean in Keras Dropout(0.5)(X)?
This question already has an answer here:
There are multiple ways that this code can work, 2 come into my mind right now:
Using the built in __call__
function of classes
>>> class MyClass:
... def __init__(self, name):
... self.name = name
... def __call__(self, word):
... print(self.name, 'says', word)
...
>>> MyClass('Tom')('hello')
Tom says hello
A function returning a function
>>> def add(a):
... def f2(b):
... print(a+b)
... return f2
...
>>> add(1)(2)
3
I hope this helps
链接地址: http://www.djcxy.com/p/12188.html上一篇: 文章,博客文章,照片,故事