This is what I tried to do.
def custom_activation(x):
return (K.sigmoid(x) * 5) - 1
layer_3 = Dense(1, activation='sigmoid', init=lambda shape, name: normal(shape, scale=1e-4, name=name))(layer_2)
I got the following error:
Exception: Invalid activation function: custom_activation
Looks like you're setting activation='sigmoid' in layer_3. If you're using your custom_activation function in layer_2 can you please share how the function is being passed?
A common construct in Keras for using custom_functions is to just use them in the argument.
For example:
Dense(activation=custom_activation)
or
model.add(Activation(custom_activation))
@abishekk92 Thanks. I actually put colons that prevented it from working well.
@ritchieng Where did you put colons? Even I am trying to use piecewise linear functions instead of sigmoid function as activation. I am stuck around the same issue. Thanks in advance.
Most helpful comment
Looks like you're setting
activation='sigmoid'inlayer_3. If you're using yourcustom_activationfunction inlayer_2can you please share how the function is being passed?A common construct in Keras for using custom_functions is to just use them in the argument.
For example:
or