{"action":"created","issue":{"url":"https://api.github.com/repos/fchollet/keras/issues/1266","labels_url":"https://api.github.com/repos/fchollet/keras/issues/1266/labels{/name}","comments_url":"https://api.github.com/repos/fchollet/keras/issues/1266/comments","events_url":"https://api.github.com/repos/fchollet/keras/issues/1266/events","html_url":"https://github.com/fchollet/keras/issues/1266","id":122101212,"number":1266,"title":"Feature request: adding layers without overwriting weights","user":{"login":"around1991","id":9053631,"avatar_url":"https://avatars.githubusercontent.com/u/9053631?v=3","gravatar_id":"","url":"https://api.github.com/users/around1991","html_url":"https://github.com/around1991","followers_url":"https://api.github.com/users/around1991/followers","following_url":"https://api.github.com/users/around1991/following{/other_user}","gists_url":"https://api.github.com/users/around1991/gists{/gist_id}","starred_url":"https://api.github.com/users/around1991/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/around1991/subscriptions","organizations_url":"https://api.github.com/users/around1991/orgs","repos_url":"https://api.github.com/users/around1991/repos","events_url":"https://api.github.com/users/around1991/events{/privacy}","received_events_url":"https://api.github.com/users/around1991/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-12-14T18:26:38Z","updated_at":"2015-12-15T02:22:20Z","closed_at":null,"body":"Currently, when we call the `add` method on Sequential (and the `add_node` method on Graph) models, `set_previous` is called, which also calls `build`. Most of the time, this results in any existing weights on the layer being re-initialised. Thus, if we want to train a layer-by-layer autoencoder (for example), we need to store the existing weights of each encoder layer before adding them to our model, and then resetting the weights again after adding. \r\n\r\nIt seems like adding a `overwrite_weights` argument to `Sequential.add` and `Graph.add_node` methods, which feeds into `set_previous` on both containers and layers, basically telling Keras not to call `Layer.build`, would simplify this considerably. This would make incorporating pre-trained layers into a model much easier, and wouldn't impact any existing APIs.\r\n\r\nThoughts?"},"comment":{"url":"https://api.github.com/repos/fchollet/keras/issues/comments/164622211","html_url":"https://github.com/fchollet/keras/issues/1266#issuecomment-164622211","issue_url":"https://api.github.com/repos/fchollet/keras/issues/1266","id":164622211,"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-12-15T02:22:20Z","updated_at":"2015-12-15T02:22:20Z","body":"One trivial workaround for you would be to set `layer.build = lambda: None` on your existing layer. `build` will be called, and won't do anything."}}