{"action":"created","issue":{"url":"https://api.github.com/repos/Lasagne/Lasagne/issues/659","repository_url":"https://api.github.com/repos/Lasagne/Lasagne","labels_url":"https://api.github.com/repos/Lasagne/Lasagne/issues/659/labels{/name}","comments_url":"https://api.github.com/repos/Lasagne/Lasagne/issues/659/comments","events_url":"https://api.github.com/repos/Lasagne/Lasagne/issues/659/events","html_url":"https://github.com/Lasagne/Lasagne/issues/659","id":147829555,"number":659,"title":"Discussion on possible design improvements","user":{"login":"fvisin","id":4639261,"avatar_url":"https://avatars.githubusercontent.com/u/4639261?v=3","gravatar_id":"","url":"https://api.github.com/users/fvisin","html_url":"https://github.com/fvisin","followers_url":"https://api.github.com/users/fvisin/followers","following_url":"https://api.github.com/users/fvisin/following{/other_user}","gists_url":"https://api.github.com/users/fvisin/gists{/gist_id}","starred_url":"https://api.github.com/users/fvisin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fvisin/subscriptions","organizations_url":"https://api.github.com/users/fvisin/orgs","repos_url":"https://api.github.com/users/fvisin/repos","events_url":"https://api.github.com/users/fvisin/events{/privacy}","received_events_url":"https://api.github.com/users/fvisin/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":39,"created_at":"2016-04-12T18:04:20Z","updated_at":"2016-10-08T13:07:19Z","closed_at":null,"body":"First of all, I'd like to take the chance to thank you for Lasagne. I tried several different frameworks built on top of Theano and none is as easy to debug, quick to extend and simple to use.\r\n\r\nThat said, there are a few things that might be improved and I would like to begin a discussion on some design choices. \r\n\r\n*Disclaimer: the following points are to be intended \"at the best of my knowledge\", i.e., I might state something wrong, or have missed an existing way to get what I want and/or some major disadvantages of my proposals.*\r\n\r\n1. Lasagne is *mostly* an object-oriented framework. Would it be possible to go fully object-oriented? The immediate advantage I see is twofold: a) layers that do something not-ordinary could override the default functions to define their \"extra-ordinary behavior\" (e.g., I recently implemented a layer with sublayers and I found a way to hack Lasagne by setting `self.input_layer` in a convenient way, but that's a sketchy solution and is difficult to read and understand), b) one would not need to always import `get_output` and `get_output_shape` when debugging in ipdb, as they would be class methods.\r\n[This old code] (https://github.com/fvisin/arctic_layers/blob/79cc6c5d5f3eab399980f5fa11e468e25641323e/layers.py#L126) that I wrote before switching to Lasagne does something in this fashion (see e.g. the `get_all_params` method).\r\n2. I couldn't find a simple and efficient way to do symbolical shape inference. Say I have multiple convolutions/pooling layers and I want to know for each of them if there has been some implicit cropping at run-time. The only way I found is to call `get_output(theLayer).shape`, but (please correct me if I am wrong!) it traverses the full graph of layers every time, which is time consuming. It would be nice to store the partial information in the Layer so that there is no need to recompute it every time. As a plus this would also allow an easy access to the `tag.test_value` of the output symbolic variable of the Layer, e.g. with `theLayer.output.tag.test_value` making debug much easier.\r\n3. The `get_all_params` helper function provides a convenient way to access all the params of the Layers of the network, filtering them by `tag`. It would be nice to add a way to filter by the name of the layer (e.g., with regexp). For similar reasons, it would be nice if the Layers of the library allowed to add custom tags to the parameters. For example [conv.py](https://github.com/Lasagne/Lasagne/blob/0440814d4e7936de8423c29bbf9d5423ccc28ee8/lasagne/layers/conv.py#L234) currently sets `regularizable=False` on the bias, but could also set other tags from a dictionary of tags provided to the constructor. One way to do it could be to add a `tags` parameter to the Layer, which would be a dictionary with as keys the names of the parameters for which we want to set a tag and as value a dictionary of tags and relative values.\r\n\r\nLet me know if any of these sounds reasonable."},"comment":{"url":"https://api.github.com/repos/Lasagne/Lasagne/issues/comments/252423705","html_url":"https://github.com/Lasagne/Lasagne/issues/659#issuecomment-252423705","issue_url":"https://api.github.com/repos/Lasagne/Lasagne/issues/659","id":252423705,"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":"2016-10-08T13:07:19Z","updated_at":"2016-10-08T13:07:19Z","body":"> in my full case I cannot use them because I reshape to shapes like `cheight * cwidth`\r\n\r\nCan you use `-1` for that, and `[0]` where you have `-1` now?\r\n\r\n> The `cache` parameter that you suggested (#659 (comment)) would work great here.\r\n\r\nHow? The problem is that you're trying to do things in the constructor that should be done in `get_output_for()`, because you don't know the input expression before that. You're trying to construct a Theano expression directly, while a Lasagne network is meant to be a function for constructing Theano expressions.\r\n\r\n> Is there another way to address that case currently?\r\n\r\nThe way it's intended would be to use a custom `MergeLayer` that has the internal `InputLayer` as an additional input, so it can grab its symbolic shape in `get_output_for()`. Writing a custom `MergeLayer` for each reshape is a bit cumbersome, though. We could have an `ExpressionLayer` that allows multiple inputs, or a `ReshapeLayer` variant that can refer to symbolic shapes of other layers."}}
{"actor":{"display_login":"f0k"}}