Repository: keras-team/keras

Issue:
Can't load `Sequential` with custom layers
Now `Sequeltial.from_config` doesn't have `cutsom_objects` argument.
`Sequential` with custom layers can create config, but can't restore from it.
Is it a specification?

And if I save/load such model, `Sequential.from_config` is called internally [here](https://github.com/fchollet/keras/blob/f4f3567e156c6b964d17e24fa4a4073f00851463/keras/utils/generic_utils.py#L136-L141). `custom_objects` is ignored and raises `ValueError: Unknown layer`.
I think it should check `custom_objects is None` if `from_config` doesn't have `custom_objects` argument.

Sample code
```python
#!/usr/bin/env python

import os
from keras.models import Model, Sequential, load_model
from keras.layers import Input, InputLayer
from keras.engine.topology import Layer

class MyLayer(Layer):
    def __init__(self, **kwargs):
        super(MyLayer, self).__init__(**kwargs)

    def call(self, inputs):
        return inputs + 1

    def compute_output_shape(self, input_shape):
        return input_shape

    def get_config(self):
        return super(MyLayer, self).get_config()

modelB = Sequential([
    InputLayer([10]),
    MyLayer()
])
modelB.save("model.h5")
try:
    load_model("model.h5", custom_objects={"MyLayer": MyLayer})  # this fails
    print("Succeeded to load modelB.")
except:
    print("Failed to load modelB.")
os.remove("model.h5")

```

***
Please make sure that the boxes below are checked before you submit your issue. If your issue is an implementation question, please ask your question on [StackOverflow](http://stackoverflow.com/questions/tagged/keras) or [join the Keras Slack channel](https://keras-slack-autojoin.herokuapp.com/) and ask there instead of filing a GitHub issue.

Thank you!

- [x] Check that you are up-to-date with the master branch of Keras. You can update with:
pip install git+git://github.com/fchollet/keras.git --upgrade --no-deps

- [x] If running on TensorFlow, check that you are up-to-date with the latest version. The installation instructions can be found [here](https://www.tensorflow.org/get_started/os_setup).

- [ ] If running on Theano, check that you are up-to-date with the master branch of Theano. You can update with:
pip install git+git://github.com/Theano/Theano.git --upgrade --no-deps

- [x] Provide a link to a GitHub Gist of a Python script that can reproduce your issue (or just copy the script here if it is short).



Discussion:

Resolving patch:
diff --git a/keras/models.py b/keras/models.py
--- a/keras/models.py
+++ b/keras/models.py
@@ -1180,13 +1180,13 @@ def get_config(self):
         return copy.deepcopy(config)
 
     @classmethod
-    def from_config(cls, config):
+    def from_config(cls, config, custom_objects=None):
         if 'class_name' not in config[0] or config[0]['class_name'] == 'Merge':
             return cls.legacy_from_config(config)
 
         model = cls()
         for conf in config:
-            layer = layer_module.deserialize(conf)
+            layer = layer_module.deserialize(conf, custom_objects=custom_objects)
             model.add(layer)
         return model
 


Test patch: