{"action":"created","issue":{"url":"https://api.github.com/repos/mila-udem/blocks/issues/723","labels_url":"https://api.github.com/repos/mila-udem/blocks/issues/723/labels{/name}","comments_url":"https://api.github.com/repos/mila-udem/blocks/issues/723/comments","events_url":"https://api.github.com/repos/mila-udem/blocks/issues/723/events","html_url":"https://github.com/mila-udem/blocks/issues/723","id":88959273,"number":723,"title":"Refactor Linear and Convolutional to allow messing with the parameters in subclasses","user":{"login":"dwf","id":60206,"avatar_url":"https://avatars.githubusercontent.com/u/60206?v=3","gravatar_id":"","url":"https://api.github.com/users/dwf","html_url":"https://github.com/dwf","followers_url":"https://api.github.com/users/dwf/followers","following_url":"https://api.github.com/users/dwf/following{/other_user}","gists_url":"https://api.github.com/users/dwf/gists{/gist_id}","starred_url":"https://api.github.com/users/dwf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dwf/subscriptions","organizations_url":"https://api.github.com/users/dwf/orgs","repos_url":"https://api.github.com/users/dwf/repos","events_url":"https://api.github.com/users/dwf/events{/privacy}","received_events_url":"https://api.github.com/users/dwf/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/mila-udem/blocks/labels/refactor","name":"refactor","color":"5319e7"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-06-17T08:53:08Z","updated_at":"2015-06-20T06:38:11Z","closed_at":null,"body":"Case in point: a brick that always masks its weights with a certain pattern. Reusing the code in the apply method is not easy because it is using the object attributes for the parameters.\r\n\r\nI think the easiest thing to do is put the meat of the operation in a private static method that takes parameters and input as arguments, that gets called by the apply method. A subclasser can either call super() to get the apply of the superclass (if they want to do some post-processing) or call the static method themselves with whatever arguments they like (if they want to do some pre-processing of the parameters).\r\n\r\n* call super()\r\n\r\n@rizar Curious as to your thoughts."},"comment":{"url":"https://api.github.com/repos/mila-udem/blocks/issues/comments/113716755","html_url":"https://github.com/mila-udem/blocks/issues/723#issuecomment-113716755","issue_url":"https://api.github.com/repos/mila-udem/blocks/issues/723","id":113716755,"user":{"login":"dwf","id":60206,"avatar_url":"https://avatars.githubusercontent.com/u/60206?v=3","gravatar_id":"","url":"https://api.github.com/users/dwf","html_url":"https://github.com/dwf","followers_url":"https://api.github.com/users/dwf/followers","following_url":"https://api.github.com/users/dwf/following{/other_user}","gists_url":"https://api.github.com/users/dwf/gists{/gist_id}","starred_url":"https://api.github.com/users/dwf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dwf/subscriptions","organizations_url":"https://api.github.com/users/dwf/orgs","repos_url":"https://api.github.com/users/dwf/repos","events_url":"https://api.github.com/users/dwf/events{/privacy}","received_events_url":"https://api.github.com/users/dwf/received_events","type":"User","site_admin":false},"created_at":"2015-06-20T06:38:11Z","updated_at":"2015-06-20T06:38:11Z","body":"So  I tried what you suggested, I think:\r\n\r\n```\r\nclass Foo(Linear):\r\n    ...\r\n    def _initialize(self):\r\n        super(Foo, self)._initialize()\r\n        self.params[0] = tensor.triu(self.params[0], k=1)\r\n\r\n    @application(inputs=['input_'], outputs=['output'])\r\n    def apply(self, input_):\r\n        linear = super(Foo, self).apply(input_)\r\n        ...\r\n        ...\r\n```\r\n\r\nYou would think that this would prevent the model being learned with this brick from getting any gradient on the weights in the lower triangle of this matrix. You would be wrong.\r\n\r\n![](https://i.imgur.com/o6cM817.png)\r\n\r\nAny idea why?"}}