title: Loading a model Raise ValueError Unknown loss function
body: <p>this is the code after i try to save and load my model: </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>model.save('path_to_my_model.h5')
  del model
  model = tf.keras.models.load_model('path_to_my_model.h5', custom_objects={'Wraparound2D': Wraparound2D})
  
  import tensorflow.keras.backend as K
  
  inp = model.input                                           # input placeholder
  outputs = [layer.output for layer in model.layers]          # all layer outputs
  functor = K.function(inp, outputs)   # evaluation function
  
  layer_outs = functor([X_test, 1.])
  
  
  
  # Plot activations of different neurons in different layers 
  all_layer_activations = list()
  
  min_max_scaler = lambda x : (x - np.min(x))/(np.max(x) - np.min(x))
  # min_max_scaler = lambda x : (x - np.mean(x))
  for j in range(1, 5):
      if j==1:
          layer_im = np.hstack([min_max_scaler(layer_outs[1][0][..., i]) for i in range(10)])
      else:
          pattern = np.reshape(layer_outs[j][0], (wspan, hspan, -1))
          layer_im = np.hstack([min_max_scaler(pattern[..., i]) for i in range(10)])
      all_layer_activations.append(layer_im)</code></pre>
  </div>
  </div>
  </p>
  
  <p>but i get the following error: </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>ValueError                                Traceback (most recent call last)
  &lt;ipython-input-9-75d24275ae64&gt; in &lt;module&gt;()
       92 model.save('path_to_my_model.h5')
       93 del model
  ---&gt; 94 model = tf.keras.models.load_model('path_to_my_model.h5', custom_objects={'Wraparound2D': Wraparound2D})
       95 
       96 import tensorflow.keras.backend as K
  
  5 frames
  /usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/utils/generic_utils.py in deserialize_keras_object(identifier, module_objects, custom_objects, printable_module_name)
      390       obj = module_objects.get(object_name)
      391       if obj is None:
  --&gt; 392         raise ValueError('Unknown ' + printable_module_name + ':' + object_name)
      393     # Classes passed by name are instantiated with no args, functions are
      394     # returned as-is.
  
  ValueError: Unknown loss function: &lt;lambda&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>I can't find why I get it thanks for help. this error comes right after i try to load the model before that everything is fine</p>