{"action":"created","issue":{"url":"https://api.github.com/repos/EderSantana/seya/issues/45","repository_url":"https://api.github.com/repos/EderSantana/seya","labels_url":"https://api.github.com/repos/EderSantana/seya/issues/45/labels{/name}","comments_url":"https://api.github.com/repos/EderSantana/seya/issues/45/comments","events_url":"https://api.github.com/repos/EderSantana/seya/issues/45/events","html_url":"https://github.com/EderSantana/seya/issues/45","id":169420852,"number":45,"title":"Winner take all autoencoder update","user":{"login":"zoli333","id":13023894,"avatar_url":"https://avatars.githubusercontent.com/u/13023894?v=3","gravatar_id":"","url":"https://api.github.com/users/zoli333","html_url":"https://github.com/zoli333","followers_url":"https://api.github.com/users/zoli333/followers","following_url":"https://api.github.com/users/zoli333/following{/other_user}","gists_url":"https://api.github.com/users/zoli333/gists{/gist_id}","starred_url":"https://api.github.com/users/zoli333/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zoli333/subscriptions","organizations_url":"https://api.github.com/users/zoli333/orgs","repos_url":"https://api.github.com/users/zoli333/repos","events_url":"https://api.github.com/users/zoli333/events{/privacy}","received_events_url":"https://api.github.com/users/zoli333/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-08-04T16:46:10Z","updated_at":"2016-08-15T09:11:15Z","closed_at":null,"body":"Hi\r\n\r\nI want to update your WinnerTakeAll layer to work with the new keras. So I implemented the Spatial + lifetime algorithm based on this article with the help of your code. It works in the new keras version but I dont know if this is correct:\r\nhttp://arxiv.org/pdf/1409.2752v2.pdf\r\n\r\nHere is my code\r\n[wta.zip](https://github.com/EderSantana/seya/files/402172/wta.zip)\r\n\r\nBasically my batch size is 100, and the filters are 64 size. For example in a 100x64x5x5 tensor, there will be 100 maximum values, because the maximums are computed across 1,2,3 dimension axes (as the article mentioned). Then I drop out \"k\" of them, in this case from 100 batch and I drop 20% of them out, there will remain just 80 out of 100.\r\nThis was basically in the article when the Spatial+Lifetime winner-take-all was applied.\r\n\r\nMy question is the winnertakeall function correct? In the feed-forward case is this function returns the masked x (the k% of the maximums are zeroed out), but more importantly is it return the masked filters in the backward case? So the derivatives are computed through the non-zero values? If not how can I set this. Should I use masking here or not, because I don't know how to do this\r\n\r\nAnother question, Why the spatial and lefetime functions are interchanged? When one call the function \r\nspatial=5, lifetime=5 these conditions will be applied:\r\nif self.n_largest:\r\n                Y = self.wta_largest(Y, self.n_largest)\r\n            if self.wta_spatial:\r\n                Y = self.wta_lifetime(Y, self.spatial)\r\n            if self.wta_lifetime:\r\n                Y = self.wta_spatial(Y, self.lifetime)\r\nSo if I call the both the spatial and lifetime (these two parameters are set) and set the previous_mode to False, First I call the spatial, but this calls the lifetime function with the spatial parameter? And then if I set the lifetime parameter too (which is not set to zero its 5) then the code calls the wta_spatial function, with the lifetime parameter ? I don't understand this.\r\nCould you explain it why?\r\n\r\nThank you\r\n"},"comment":{"url":"https://api.github.com/repos/EderSantana/seya/issues/comments/239759948","html_url":"https://github.com/EderSantana/seya/issues/45#issuecomment-239759948","issue_url":"https://api.github.com/repos/EderSantana/seya/issues/45","id":239759948,"user":{"login":"zoli333","id":13023894,"avatar_url":"https://avatars.githubusercontent.com/u/13023894?v=3","gravatar_id":"","url":"https://api.github.com/users/zoli333","html_url":"https://github.com/zoli333","followers_url":"https://api.github.com/users/zoli333/followers","following_url":"https://api.github.com/users/zoli333/following{/other_user}","gists_url":"https://api.github.com/users/zoli333/gists{/gist_id}","starred_url":"https://api.github.com/users/zoli333/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zoli333/subscriptions","organizations_url":"https://api.github.com/users/zoli333/orgs","repos_url":"https://api.github.com/users/zoli333/repos","events_url":"https://api.github.com/users/zoli333/events{/privacy}","received_events_url":"https://api.github.com/users/zoli333/received_events","type":"User","site_admin":false},"created_at":"2016-08-15T09:11:14Z","updated_at":"2016-08-15T09:11:14Z","body":"Hi\r\nThese are my modifications to implement just spatial + lifetime sparsity. Sorry I don't know how to use github, so I am attaching my code.\r\n\r\n[wta.zip](https://github.com/EderSantana/seya/files/417794/wta.zip)\r\n\r\nCould you help. It runs fine with the iterations, but when autoencoder.predict(X_test) is called, the program throws the following error:\r\nmodel2.predict(X_test,X_test)\r\nTraceback (most recent call last):\r\n  File \"<stdin>\", line 1, in <module>\r\n  File \"/usr/local/lib/python2.7/dist-packages/keras/models.py\", line 648, in predict\r\n    return self.model.predict(x, batch_size=batch_size, verbose=verbose)\r\n  File \"/usr/local/lib/python2.7/dist-packages/keras/engine/training.py\", line 1180, in predict\r\n    batch_size=batch_size, verbose=verbose)\r\n  File \"/usr/local/lib/python2.7/dist-packages/keras/engine/training.py\", line 869, in _predict_loop\r\n    batches = make_batches(nb_sample, batch_size)\r\n  File \"/usr/local/lib/python2.7/dist-packages/keras/engine/training.py\", line 281, in make_batches\r\n    nb_batch = int(np.ceil(size / float(batch_size)))\r\nTypeError: only length-1 arrays can be converted to Python scalars\r\n>>> model2.predict(X_tes)\r\nTraceback (most recent call last):\r\n  File \"<stdin>\", line 1, in <module>\r\nNameError: name 'X_tes' is not defined\r\n>>> model2.predict(X_test)\r\nTraceback (most recent call last):\r\n  File \"<stdin>\", line 1, in <module>\r\n  File \"/usr/local/lib/python2.7/dist-packages/keras/models.py\", line 648, in predict\r\n    return self.model.predict(x, batch_size=batch_size, verbose=verbose)\r\n  File \"/usr/local/lib/python2.7/dist-packages/keras/engine/training.py\", line 1180, in predict\r\n    batch_size=batch_size, verbose=verbose)\r\n  File \"/usr/local/lib/python2.7/dist-packages/keras/engine/training.py\", line 879, in _predict_loop\r\n    batch_outs = f(ins_batch)\r\n  File \"/usr/local/lib/python2.7/dist-packages/keras/backend/theano_backend.py\", line 657, in __call__\r\n    return self.function(*inputs)\r\n  File \"/usr/local/lib/python2.7/dist-packages/theano/compile/function_module.py\", line 879, in __call__\r\n    storage_map=getattr(self.fn, 'storage_map', None))\r\n  File \"/usr/local/lib/python2.7/dist-packages/theano/gof/link.py\", line 325, in raise_with_op\r\n    reraise(exc_type, exc_value, exc_trace)\r\n  File \"/usr/local/lib/python2.7/dist-packages/theano/compile/function_module.py\", line 866, in __call__\r\n    self.fn() if output_subset is None else\\\r\nIndexError: index out of bounds\r\nApply node that caused the error: Subtensor{int64}(SortOp{quicksort, None}.0, Constant{-20})\r\nToposort index: 29\r\nInputs types: [TensorType(float32, 4D), Scalar(int64)]\r\nInputs shapes: [(10, 64, 28, 28), ()]\r\nInputs strides: [(200704, 3136, 112, 4), ()]\r\nInputs values: ['not shown', -20]\r\nOutputs clients: [[InplaceDimShuffle{x,0,1,2}(Subtensor{int64}.0)]]\r\n\r\nBacktrace when the node is created(use Theano flag traceback.limit=N to make it longer):\r\n  File \"<stdin>\", line 1, in <module>\r\n  File \"/usr/local/lib/python2.7/dist-packages/keras/models.py\", line 307, in add\r\n    output_tensor = layer(self.outputs[0])\r\n  File \"/usr/local/lib/python2.7/dist-packages/keras/engine/topology.py\", line 511, in __call__\r\n    self.add_inbound_node(inbound_layers, node_indices, tensor_indices)\r\n  File \"/usr/local/lib/python2.7/dist-packages/keras/engine/topology.py\", line 569, in add_inbound_node\r\n    Node.create_node(self, inbound_layers, node_indices, tensor_indices)\r\n  File \"/usr/local/lib/python2.7/dist-packages/keras/engine/topology.py\", line 150, in create_node\r\n    output_tensors = to_list(outbound_layer.call(input_tensors[0], mask=input_masks[0]))\r\n  File \"<stdin>\", line 40, in call\r\n\r\nI appreciate your help\r\n\r\n"}}
{"actor":{"display_login":"zoli333"}}