{"action":"created","issue":{"url":"https://api.github.com/repos/Lasagne/Lasagne/issues/299","labels_url":"https://api.github.com/repos/Lasagne/Lasagne/issues/299/labels{/name}","comments_url":"https://api.github.com/repos/Lasagne/Lasagne/issues/299/comments","events_url":"https://api.github.com/repos/Lasagne/Lasagne/issues/299/events","html_url":"https://github.com/Lasagne/Lasagne/issues/299","id":87838455,"number":299,"title":"RFC: Unify conv/pool layers","user":{"login":"craffel","id":417568,"avatar_url":"https://avatars.githubusercontent.com/u/417568?v=3","gravatar_id":"","url":"https://api.github.com/users/craffel","html_url":"https://github.com/craffel","followers_url":"https://api.github.com/users/craffel/followers","following_url":"https://api.github.com/users/craffel/following{/other_user}","gists_url":"https://api.github.com/users/craffel/gists{/gist_id}","starred_url":"https://api.github.com/users/craffel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/craffel/subscriptions","organizations_url":"https://api.github.com/users/craffel/orgs","repos_url":"https://api.github.com/users/craffel/repos","events_url":"https://api.github.com/users/craffel/events{/privacy}","received_events_url":"https://api.github.com/users/craffel/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-06-12T20:18:38Z","updated_at":"2015-06-12T20:46:14Z","closed_at":null,"body":"It has come up a couple of times as I have introduced people (cc @bmcfee, @moscow25, and issue #128) to Lasagne that someone is trying to use some code which uses, for example, `Conv2DDNNLayer` on a machine which has no GPU or does not have cudnn installed (this can happen when you're running someone else's code, or when you want to test out some code you wrote on your GPU box on your GPU-less laptop).  The simple fix is generally to just use `Conv2DLayer` instead, but it's not really a portable solution to tell people to modify code when it's being used on different systems.  A simple hack fix would be for all scripts which use Lasagne's layers which have optional dependencies to have something like this (as an example) at the top:\r\n```Python\r\ntry:\r\n    import lasagne.layers.dnn\r\n    conv_layer = lasagne.layers.dnn.Conv2DNNLayer\r\nexcept ImportError:\r\n    conv_layer = lasagne.layers.Conv2DLayer\r\n...\r\n# All convolutional layers would then be instantiated like this\r\nlayer = conv_layer(incoming, ...)\r\n```\r\nI don't really think it's fair to encourage all of our users to do something this hacky, though, and I think we owe it to users to abstract this out.  To me, a good solution would be for there to be a single `Conv2DLayer` which had an additional kwarg such as `backend`, which could be, say, `'theano'`, `'cuda_convnet'`, `'dnn'`, etc., which chose which backend to use.  Given that the different backends have different requirements, we'd need to be diligent (as we already are) about throwing errors when a backend can't support the provided layer arguments.  The simplest way to implement this would be to basically just make `Conv2DLayer` a wrapper class around all of these layers, which threw warnings when it fell back on the theano backend because of something not being present.  I believe this also applies to pooling layers.  If and when theano does this for us, we can greatly simplify our code, but I think it's worth abstracting this out now instead of waiting.  I don't have enough in-depth knowledge of the different layers/backends to know if there is something making this not possible, so please let me know if there is."},"comment":{"url":"https://api.github.com/repos/Lasagne/Lasagne/issues/comments/111610168","html_url":"https://github.com/Lasagne/Lasagne/issues/299#issuecomment-111610168","issue_url":"https://api.github.com/repos/Lasagne/Lasagne/issues/299","id":111610168,"user":{"login":"ebenolson","id":544718,"avatar_url":"https://avatars.githubusercontent.com/u/544718?v=3","gravatar_id":"","url":"https://api.github.com/users/ebenolson","html_url":"https://github.com/ebenolson","followers_url":"https://api.github.com/users/ebenolson/followers","following_url":"https://api.github.com/users/ebenolson/following{/other_user}","gists_url":"https://api.github.com/users/ebenolson/gists{/gist_id}","starred_url":"https://api.github.com/users/ebenolson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ebenolson/subscriptions","organizations_url":"https://api.github.com/users/ebenolson/orgs","repos_url":"https://api.github.com/users/ebenolson/repos","events_url":"https://api.github.com/users/ebenolson/events{/privacy}","received_events_url":"https://api.github.com/users/ebenolson/received_events","type":"User","site_admin":false},"created_at":"2015-06-12T20:46:14Z","updated_at":"2015-06-12T20:46:14Z","body":"Another way to do this would be to add code to `cuda_convnet.py` and `dnn.py` which replaces those Layer classes with dummy wrappers around `Conv2DLayer` when the libraries are unavailable.\r\n\r\nOne complication is that `Conv2DLayer` doesn't support `pad` at the moment.\r\n "}}