title: keras.module.load_model raise TypeError('Keyword argument not understood:', kwarg)
body: <p>I'm trying to perform transfer learning on a mobilenet using Keras and the Flower DB provided for example in tf. The training works well and I perform predictions but I'm not able to save the model to future use so I have to perform training every time.</p>
  
  <p>I'm working on MACOS Mojave with python 3.7 and the lastest update of Keras, already performed pip --upgrade keras.</p>
  
  <pre class="lang-py prettyprint-override"><code>feature_extractor_url = "https://tfhub.dev/google/imagenet/mobilenet_v2_100_224/feature_vector/2" #@param {type:"string"}
  
  # Create the module, and check the expected image size:
  def feature_extractor(x):
    feature_extractor_module = hub.Module(feature_extractor_url)
    return feature_extractor_module(x)
  
  IMAGE_SIZE = hub.get_expected_image_size(hub.Module(feature_extractor_url))
  
  # Ensure the data generator is generating images of the expected size:
  image_data = image_generator.flow_from_directory(str(data_root), target_size=IMAGE_SIZE, subset='training')
  test_data = image_generator.flow_from_directory(str(data_root), target_size=IMAGE_SIZE, subset='validation')
  
  # Wrap the module in a keras layer.
  features_extractor_layer = layers.Lambda(feature_extractor, input_shape=IMAGE_SIZE+[3])
  # Freeze the variables in the feature extractor layer, so that the training only modifies the new classifier layer.
  features_extractor_layer.trainable = False
  
  # Attach a classification head
  # Now wrap the hub layer in a tf.keras.Sequential model, and add a new classification layer.
  model = tf.keras.Sequential([
    features_extractor_layer,
    layers.Dense(image_data.num_classes, activation='softmax')
  ])
  
  # Initialize the TFHub module.
  import tensorflow.keras.backend as K
  sess = K.get_session()
  init = tf.global_variables_initializer()
  sess.run(init)
  
  # Train the model
  model.compile(
    optimizer= tf.keras.optimizers.Adam(),
    loss='categorical_crossentropy',
    metrics=['accuracy'])
  
  model.fit((item for item in image_data), epochs=1,
                      steps_per_epoch=steps_per_epoch,
                      callbacks = [batch_stats])
  
  model.save("./saved_models/flower_model.h5")
  
  del model
  
  from keras.models import load_model
  model = load_model('./saved_models/flower_model.h5')
  model.summary()
  </code></pre>
  
  <p>model.save() seems working fine, the file flower_model.h5 is correctly created at the directory but when runing load_model() the output error is:</p>
  
  <pre><code>Using TensorFlow backend.
  Traceback (most recent call last):
    File "/Users/david/Library/Preferences/PyCharmCE2018.2/scratches/retrain_flowers.py", line 114, in &lt;module&gt;
      model = load_model('./saved_models/flower_model.h5')
    File "/Users/david/Library/Python/3.7/lib/python/site-packages/keras/engine/saving.py", line 419, in load_model
      model = _deserialize_model(f, custom_objects, compile)
    File "/Users/david/Library/Python/3.7/lib/python/site-packages/keras/engine/saving.py", line 225, in _deserialize_model
      model = model_from_config(model_config, custom_objects=custom_objects)
    File "/Users/david/Library/Python/3.7/lib/python/site-packages/keras/engine/saving.py", line 458, in model_from_config
      return deserialize(config, custom_objects=custom_objects)
    File "/Users/david/Library/Python/3.7/lib/python/site-packages/keras/layers/__init__.py", line 55, in deserialize
      printable_module_name='layer')
    File "/Users/david/Library/Python/3.7/lib/python/site-packages/keras/utils/generic_utils.py", line 145, in deserialize_keras_object
      list(custom_objects.items())))
    File "/Users/david/Library/Python/3.7/lib/python/site-packages/keras/engine/sequential.py", line 300, in from_config
      custom_objects=custom_objects)
    File "/Users/david/Library/Python/3.7/lib/python/site-packages/keras/layers/__init__.py", line 55, in deserialize
      printable_module_name='layer')
    File "/Users/david/Library/Python/3.7/lib/python/site-packages/keras/utils/generic_utils.py", line 145, in deserialize_keras_object
      list(custom_objects.items())))
    File "/Users/david/Library/Python/3.7/lib/python/site-packages/keras/layers/core.py", line 764, in from_config
      return cls(**config)
    File "/Users/david/Library/Python/3.7/lib/python/site-packages/keras/legacy/interfaces.py", line 91, in wrapper
      return func(*args, **kwargs)
    File "/Users/david/Library/Python/3.7/lib/python/site-packages/keras/layers/core.py", line 626, in __init__
      super(Lambda, self).__init__(**kwargs)
    File "/Users/david/Library/Python/3.7/lib/python/site-packages/keras/engine/base_layer.py", line 128, in __init__
      raise TypeError('Keyword argument not understood:', kwarg)
  TypeError: ('Keyword argument not understood:', 'module')
  </code></pre>
  
  <p>I would like to load the model in a different script so I can perform detection, I'm not sure if I should initialize something before loading the model. Thanks for taking the time to read my question.</p>