Skip to content
Advertisement

How do you use Keras LeakyReLU in Python?

I am trying to produce a CNN using Keras, and wrote the following code:

JavaScript

I want to use Keras’s LeakyReLU activation layer instead of using Activation('relu'). However, I tried using LeakyReLU(alpha=0.1) in place, but this is an activation layer in Keras, and I get an error about using an activation layer and not an activation function.

How can I use LeakyReLU in this example?

Advertisement

Answer

All advanced activations in Keras, including LeakyReLU, are available as layers, and not as activations; therefore, you should use it as such:

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement