Skip to content Skip to sidebar Skip to footer

A 'concatenate' Layer Should Be Called On A List Of At Least 2 Inputs

I am trying to implement a conv-net in Keras, where I am planning to separate layers into units for different parametric activation functions, and then recombine these units using

Solution 1:

Rewrite your function like this:

def op(x, units, kernel, stride, activation):
    x_list = []
    for i in range(units):
        x_list.append(L.Conv2D(1, kernel, stride, activation=activation)(x))
    x = L.Concatenate(-1)(x_list)
    return x

The += operator on a list does not do what you think it does, in the end it is kind of concatenating all tensors instead of adding them to a list. Use append for the intended effect.

Solution 2:

I think your error is with the scope of 'L'. You declare it in the for loop. So, when the loop is finished, L is erased. Maybe adding something like

L=""

Before the for loop should solve your issue?

Post a Comment for "A 'concatenate' Layer Should Be Called On A List Of At Least 2 Inputs"