{"action":"created","issue":{"url":"https://api.github.com/repos/fchollet/keras/issues/775","labels_url":"https://api.github.com/repos/fchollet/keras/issues/775/labels{/name}","comments_url":"https://api.github.com/repos/fchollet/keras/issues/775/comments","events_url":"https://api.github.com/repos/fchollet/keras/issues/775/events","html_url":"https://github.com/fchollet/keras/pull/775","id":109641622,"number":775,"title":"First crack at threading `custom_layers` through.","user":{"login":"stephenbalaban","id":530667,"avatar_url":"https://avatars.githubusercontent.com/u/530667?v=3","gravatar_id":"","url":"https://api.github.com/users/stephenbalaban","html_url":"https://github.com/stephenbalaban","followers_url":"https://api.github.com/users/stephenbalaban/followers","following_url":"https://api.github.com/users/stephenbalaban/following{/other_user}","gists_url":"https://api.github.com/users/stephenbalaban/gists{/gist_id}","starred_url":"https://api.github.com/users/stephenbalaban/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stephenbalaban/subscriptions","organizations_url":"https://api.github.com/users/stephenbalaban/orgs","repos_url":"https://api.github.com/users/stephenbalaban/repos","events_url":"https://api.github.com/users/stephenbalaban/events{/privacy}","received_events_url":"https://api.github.com/users/stephenbalaban/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-10-03T19:49:54Z","updated_at":"2015-10-04T00:25:06Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/fchollet/keras/pulls/775","html_url":"https://github.com/fchollet/keras/pull/775","diff_url":"https://github.com/fchollet/keras/pull/775.diff","patch_url":"https://github.com/fchollet/keras/pull/775.patch"},"body":"Keras currently uses globals() to access layers. (This doesn't work\r\nacross modules.) Hacky solution was to pass a dict mapping name -> class.\r\nI called this dict `custom_layers`. I have a few questions before we merge this in:\r\n\r\n1. What would be a better name for this kwarg? `user_layers`? `layers`?\r\n2. Is there a better way of doing this that I'm not seeing?\r\n3. Are there any other places I missed that where should add the `custom_layers` argument?\r\n\r\nCurrently serialziation with custom layers works fine. The problem that this fixes is trying to call `model_from_*` with a configuration file that has a custom layer name that isn't inside of Keras' `globals()`. This solution allows us to serialize / deserialize models with custom layers. For example:\r\n\r\n```py\r\nfrom keras.models import model_from_yaml\r\nimport keras.layers.core\r\n\r\nclass FooLayer(keras.layers.core.Layer):\r\n    pass\r\n\r\nmy_layers = {\r\n    'FooLayer': FooLayer\r\n}\r\n\r\nwith open('foo-network.yaml', 'r') as cfg:\r\n    model = model_from_yaml(cfg.read(), custom_layers=my_layers)\r\n```"},"comment":{"url":"https://api.github.com/repos/fchollet/keras/issues/comments/145301643","html_url":"https://github.com/fchollet/keras/pull/775#issuecomment-145301643","issue_url":"https://api.github.com/repos/fchollet/keras/issues/775","id":145301643,"user":{"login":"fchollet","id":710255,"avatar_url":"https://avatars.githubusercontent.com/u/710255?v=3","gravatar_id":"","url":"https://api.github.com/users/fchollet","html_url":"https://github.com/fchollet","followers_url":"https://api.github.com/users/fchollet/followers","following_url":"https://api.github.com/users/fchollet/following{/other_user}","gists_url":"https://api.github.com/users/fchollet/gists{/gist_id}","starred_url":"https://api.github.com/users/fchollet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fchollet/subscriptions","organizations_url":"https://api.github.com/users/fchollet/orgs","repos_url":"https://api.github.com/users/fchollet/repos","events_url":"https://api.github.com/users/fchollet/events{/privacy}","received_events_url":"https://api.github.com/users/fchollet/received_events","type":"User","site_admin":false},"created_at":"2015-10-04T00:25:06Z","updated_at":"2015-10-04T00:25:06Z","body":"> What would be a better name for this kwarg? user_layers? layers?\r\n\r\n`custom_layers` is fine."}}