I am analyzing Python code and I don’t understand what the function call x_class = Convolution2D means (num_anchors, (1, 1), activation = 'sigmoid', kernel_initializer = 'uniform', name = 'rpn_out_class') (x)

That is, the function call has the form: x_class = Convolution2D (params) (x)

In other languages ​​I have not seen such constructions. (params) - this is understandable, but why are there second brackets with X? Or just say the name of such a structure - look for the name.

    1 answer 1

    In python, a function is a full-fledged object that can both be passed as an argument and (in this case) returned as a value.

    That is, Convolution2D (params) inside itself, using the passed parameters, constructs a certain function and returns it as a result, which is immediately called with argument x. And already the result of calling this second function is written to x_class.

    Perhaps this simplified example will help you better understand how it works:

    def get_operation(symbol): def plus(a, b): return a+b def minus(a, b): return ab if symbol == '+': return plus if symbol == '-': return minus operation = get_operation('+') print(operation(5, 3)) # Напечатает: 8 operation = get_operation('-') print(operation(5, 3)) # Напечатает: 2 # И вот пример, где возвращаемая функция вызывается сразу, как в вашем вопросе: print( get_operation('+')(4, 7) ) # Напечатает: 11 
    • Yeah, now I understand. Thank! - vitaly-pos