{"action":"created","issue":{"url":"https://api.github.com/repos/benanne/Lasagne/issues/164","labels_url":"https://api.github.com/repos/benanne/Lasagne/issues/164/labels{/name}","comments_url":"https://api.github.com/repos/benanne/Lasagne/issues/164/comments","events_url":"https://api.github.com/repos/benanne/Lasagne/issues/164/events","html_url":"https://github.com/benanne/Lasagne/issues/164","id":60698112,"number":164,"title":"API: get_params()","user":{"login":"f0k","id":629706,"avatar_url":"https://avatars.githubusercontent.com/u/629706?v=3","gravatar_id":"","url":"https://api.github.com/users/f0k","html_url":"https://github.com/f0k","followers_url":"https://api.github.com/users/f0k/followers","following_url":"https://api.github.com/users/f0k/following{/other_user}","gists_url":"https://api.github.com/users/f0k/gists{/gist_id}","starred_url":"https://api.github.com/users/f0k/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/f0k/subscriptions","organizations_url":"https://api.github.com/users/f0k/orgs","repos_url":"https://api.github.com/users/f0k/repos","events_url":"https://api.github.com/users/f0k/events{/privacy}","received_events_url":"https://api.github.com/users/f0k/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-03-11T17:42:49Z","updated_at":"2015-03-12T10:28:26Z","closed_at":null,"body":"As observed in #141 (but also in #110 and https://github.com/benanne/Lasagne/issues/136#issuecomment-75169847), it's not entirely clear what `Layer.get_params()` means and what it should mean.\r\n\r\nThe documentation of `get_params()` says: \"Returns a list of all the Theano variables that parameterize the layer.\", and further below it says \"it should be overridden in a subclass that has trainable parameters\".\r\nIn addition, we have `get_bias_params()`, which is documented as: \"Returns a list of all the Theano variables that are bias parameters for the layer.\", and a note further below says \"This is useful when specifying regularization (it is often undesirable to regularize bias parameters).\"\r\n\r\nNow when we include the use case of Batch Normalization, we actually have three overlapping classes of variables:\r\n\r\n1. variables involved in the forward pass (currently `get_params()` according to its docstring)\r\n2. variables to be updated wrt. the loss function (currently `get_params()` according to its usage in Lasagne)\r\n3. variables to be updated wrt. the loss function that are not to be included in weight regularization (currently `get_bias_params()`)\r\n\r\nBefore the first release of Lasagne we should re-think the `get_params` and `get_bias_params` API. It obviously does not exactly match what comes up in the use cases. Should we possibly replace this with a single `get_params()` method with optional keyword arguments to filter out certain things? Most Layer classes would not need to bother with the keywords or just react on the bias-related keyword, so it wouldn't increase the complexity of adding a new Layer class. Shall we think that through?"},"comment":{"url":"https://api.github.com/repos/benanne/Lasagne/issues/comments/78455547","html_url":"https://github.com/benanne/Lasagne/issues/164#issuecomment-78455547","issue_url":"https://api.github.com/repos/benanne/Lasagne/issues/164","id":78455547,"user":{"login":"f0k","id":629706,"avatar_url":"https://avatars.githubusercontent.com/u/629706?v=3","gravatar_id":"","url":"https://api.github.com/users/f0k","html_url":"https://github.com/f0k","followers_url":"https://api.github.com/users/f0k/followers","following_url":"https://api.github.com/users/f0k/following{/other_user}","gists_url":"https://api.github.com/users/f0k/gists{/gist_id}","starred_url":"https://api.github.com/users/f0k/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/f0k/subscriptions","organizations_url":"https://api.github.com/users/f0k/orgs","repos_url":"https://api.github.com/users/f0k/repos","events_url":"https://api.github.com/users/f0k/events{/privacy}","received_events_url":"https://api.github.com/users/f0k/received_events","type":"User","site_admin":false},"created_at":"2015-03-12T10:28:26Z","updated_at":"2015-03-12T10:28:26Z","body":"Implementation-wise it would be good to only have keywords that restrict the set of returned variables, no keywords that extend it. Not giving any keywords would equal to \"return all variables involved in the forward pass\" then (note that I explicitly say \"variables\", not \"parameters\" -- constant parameters that are set in the constructor, such as the dropout rate for the `DropoutLayer`, should not be returned here). Implementations oblivious to keywords would look like:\r\n```python\r\ndef get_params(self, **kwargs):\r\n    return [self.X, self.Y, self.Z]\r\n```\r\nOther implementations would look like:\r\n```python\r\ndef get_params(self, **kwargs):\r\n    result = [self.W]\r\n    if not kwargs.get('no_biases'):\r\n        result += [self.b]\r\n    if not kwargs.get('trainable_only'):\r\n        result += [self.asdf]\r\n    return result\r\n```\r\nWe'd just need to decide on the terms to use. I don't really like `no_biases` because what we really wanted was to exclude parameters that are not to be regularized, such as the initial state vectors in #110. I'm not terribly sure about `trainable_only` either.\r\n\r\nIn any case, we should drop `get_bias_params()` when we revamped `get_params()`. That's an interface change we need to do before the first release. @benanne, can you please set the milestone? (I'm not allowed to.)"}}