title: Keras ValueError: Unknown activation function:<lambda>
body: <p>I'm using a lambda function to create a custom activation function but when I try to upload a checkpoint I get the error:</p>
  
  <pre><code>ValueError: Unknown activation function:&lt;lambda&gt; 
  </code></pre>
  
  <p>The function is:</p>
  
  <pre><code>lrelu = lambda x: tf.keras.activations.relu(x, alpha=0.2)
  </code></pre>
  
  <p>and used like this:</p>
  
  <pre><code>Conv2D(filters=96, kernel_size=(3,3),strides=(2,2),activation=lrelu)
  </code></pre>
  
  <p>I tried to add the custom_objects with no luck:</p>
  
  <pre><code>model = load_model(filepath, custom_objects = {"lrelu": lrelu})
  </code></pre>
  
  <p>I know I can replace my function with an extra layer and avoid this problem, but I was wondering if there is a way to make this work.</p>
  
  <p>Thanks.</p>