What does this syntax mean in Keras Dropout(0.5)(X)?

This question already has an answer here:

  • How to pair socks from a pile efficiently? 36 answers
  • Python functions with multiple parameter brackets 3 answers
  • Syntax of Keras Functional API 2 answers

  • 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

    上一篇: 文章,博客文章,照片,故事

    下一篇: Keras Dropout(0.5)(X)中的语法是什么意思?