{"action":"created","issue":{"url":"https://api.github.com/repos/fchollet/keras/issues/267","labels_url":"https://api.github.com/repos/fchollet/keras/issues/267/labels{/name}","comments_url":"https://api.github.com/repos/fchollet/keras/issues/267/comments","events_url":"https://api.github.com/repos/fchollet/keras/issues/267/events","html_url":"https://github.com/fchollet/keras/pull/267","id":90379382,"number":267,"title":"Add a name parameter to Dense.__init__","user":{"login":"julienr","id":506602,"avatar_url":"https://avatars.githubusercontent.com/u/506602?v=3","gravatar_id":"","url":"https://api.github.com/users/julienr","html_url":"https://github.com/julienr","followers_url":"https://api.github.com/users/julienr/followers","following_url":"https://api.github.com/users/julienr/following{/other_user}","gists_url":"https://api.github.com/users/julienr/gists{/gist_id}","starred_url":"https://api.github.com/users/julienr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/julienr/subscriptions","organizations_url":"https://api.github.com/users/julienr/orgs","repos_url":"https://api.github.com/users/julienr/repos","events_url":"https://api.github.com/users/julienr/events{/privacy}","received_events_url":"https://api.github.com/users/julienr/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-06-23T12:50:59Z","updated_at":"2015-06-26T08:09:15Z","closed_at":"2015-06-25T23:43:34Z","pull_request":{"url":"https://api.github.com/repos/fchollet/keras/pulls/267","html_url":"https://github.com/fchollet/keras/pull/267","diff_url":"https://github.com/fchollet/keras/pull/267.diff","patch_url":"https://github.com/fchollet/keras/pull/267.patch"},"body":"When debugging theano errors, if the error message contains a variable name, it will print something like ``<CudaNdarrayType(float32, matrix)>``, which is not very useful. With this change, a ``name`` parameter can be supplied to ``Dense.__init__`` function and the variables of the layer will be named with 'layername_varname' which make debugging easier.\r\n\r\nFor example, a theano error message before this change :\r\n\r\n```\r\nDisconnectedInputError: grad method was asked to compute the gradient with respect to a variable \r\nthat is not part of the computational graph of the cost, or is used only by a non-differentiable \r\noperator: <CudaNdarrayType(float32, matrix)>\r\n```\r\n\r\nAnd after (with my layer named 'in0') :\r\n\r\n```\r\nDisconnectedInputError: grad method was asked to compute the gradient with respect to a variable \r\nthat is not part of the computational graph of the cost, or is used only by a non-differentiable \r\noperator: in0_W\r\n```\r\n\r\n\r\nFor now, this only changes ``Dense.__init__``, but if you think this is an interesting change, I'll add the same parameter to other layers."},"comment":{"url":"https://api.github.com/repos/fchollet/keras/issues/comments/115568244","html_url":"https://github.com/fchollet/keras/pull/267#issuecomment-115568244","issue_url":"https://api.github.com/repos/fchollet/keras/issues/267","id":115568244,"user":{"login":"julienr","id":506602,"avatar_url":"https://avatars.githubusercontent.com/u/506602?v=3","gravatar_id":"","url":"https://api.github.com/users/julienr","html_url":"https://github.com/julienr","followers_url":"https://api.github.com/users/julienr/followers","following_url":"https://api.github.com/users/julienr/following{/other_user}","gists_url":"https://api.github.com/users/julienr/gists{/gist_id}","starred_url":"https://api.github.com/users/julienr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/julienr/subscriptions","organizations_url":"https://api.github.com/users/julienr/orgs","repos_url":"https://api.github.com/users/julienr/repos","events_url":"https://api.github.com/users/julienr/events{/privacy}","received_events_url":"https://api.github.com/users/julienr/received_events","type":"User","site_admin":false},"created_at":"2015-06-26T08:09:15Z","updated_at":"2015-06-26T08:09:15Z","body":"I agree that it would be better to add it to the base Layer class.\r\n\r\nSo this would add a ``name=None`` parameter ``Layer.__init__`` that is saved to self.name. This require modifying all of the layer subclasses' constructors to have a new name parameter that is forwarded to ``super().__init__``\r\n\r\nWe would also need to modify ``get_config`` to make sure subclasses call super.get_config and merge their own config with that of the parent class (so the layer_name gets automatically set).\r\n\r\nIf that sounds good, I'll go ahead and start working on another pull request.\r\n"}}