{"action":"created","issue":{"url":"https://api.github.com/repos/fstrub95/nnsparse/issues/1","labels_url":"https://api.github.com/repos/fstrub95/nnsparse/issues/1/labels{/name}","comments_url":"https://api.github.com/repos/fstrub95/nnsparse/issues/1/comments","events_url":"https://api.github.com/repos/fstrub95/nnsparse/issues/1/events","html_url":"https://github.com/fstrub95/nnsparse/issues/1","id":113402847,"number":1,"title":"SparseLinearBatch implementation","user":{"login":"davidBelanger","id":1179562,"avatar_url":"https://avatars.githubusercontent.com/u/1179562?v=3","gravatar_id":"","url":"https://api.github.com/users/davidBelanger","html_url":"https://github.com/davidBelanger","followers_url":"https://api.github.com/users/davidBelanger/followers","following_url":"https://api.github.com/users/davidBelanger/following{/other_user}","gists_url":"https://api.github.com/users/davidBelanger/gists{/gist_id}","starred_url":"https://api.github.com/users/davidBelanger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidBelanger/subscriptions","organizations_url":"https://api.github.com/users/davidBelanger/orgs","repos_url":"https://api.github.com/users/davidBelanger/repos","events_url":"https://api.github.com/users/davidBelanger/events{/privacy}","received_events_url":"https://api.github.com/users/davidBelanger/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"fstrub95","id":13366148,"avatar_url":"https://avatars.githubusercontent.com/u/13366148?v=3","gravatar_id":"","url":"https://api.github.com/users/fstrub95","html_url":"https://github.com/fstrub95","followers_url":"https://api.github.com/users/fstrub95/followers","following_url":"https://api.github.com/users/fstrub95/following{/other_user}","gists_url":"https://api.github.com/users/fstrub95/gists{/gist_id}","starred_url":"https://api.github.com/users/fstrub95/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fstrub95/subscriptions","organizations_url":"https://api.github.com/users/fstrub95/orgs","repos_url":"https://api.github.com/users/fstrub95/repos","events_url":"https://api.github.com/users/fstrub95/events{/privacy}","received_events_url":"https://api.github.com/users/fstrub95/received_events","type":"User","site_admin":false},"milestone":null,"comments":2,"created_at":"2015-10-26T17:03:28Z","updated_at":"2015-10-29T13:45:13Z","closed_at":null,"body":"I was just browsing the web for stuff for sparse data in torch. It looks like this repo is being developed right now, so I totally understand if the stuff I'm reading on github.com isn't in a stable state, isn't fully optimized, etc.\r\n\r\nI just want to point out that SparseLinearBatch:accGradParameters() might not being implemented as efficiently as possible. I think the code I pasted below is operationally equivalent, since the SparseLinearAccGradParameters already adds the grad parameters for the current computation, rather than replacing it. You don't need to manage an accumulator outside of the one already provided in self.layer. This avoids unnecessary computation in the inner loop.\r\n\r\nfunction SparseLinearBatch:accGradParameters(input, gradOutput)\r\n\r\n   if torch.isTensor(input) then \r\n      self.layer:accGradParameters(input, gradOutput)\r\n\r\n   elseif type(input) == \"table\" then\r\n\r\n      -- initialize memory without parasatizing non-batch method\r\n      self.gradWeightBuf = self.gradWeightBuf or torch.zeros(self.layer.gradWeight:size())\r\n      self.gradBiasBuf   = self.gradBiasBuf   or torch.zeros(self.layer.gradBias:size())\r\n\r\n      local k = 0\r\n      for _, oneInput in pairs(input) do\r\n         k = k + 1\r\n         self.layer:accGradParameters(oneInput, gradOutput[k])\r\n      end\r\n\r\n   else\r\n      error('input must be a either a 2D matrices or a table of 2D matrices')\r\n   end\r\n\r\nend"},"comment":{"url":"https://api.github.com/repos/fstrub95/nnsparse/issues/comments/152183247","html_url":"https://github.com/fstrub95/nnsparse/issues/1#issuecomment-152183247","issue_url":"https://api.github.com/repos/fstrub95/nnsparse/issues/1","id":152183247,"user":{"login":"fstrub95","id":13366148,"avatar_url":"https://avatars.githubusercontent.com/u/13366148?v=3","gravatar_id":"","url":"https://api.github.com/users/fstrub95","html_url":"https://github.com/fstrub95","followers_url":"https://api.github.com/users/fstrub95/followers","following_url":"https://api.github.com/users/fstrub95/following{/other_user}","gists_url":"https://api.github.com/users/fstrub95/gists{/gist_id}","starred_url":"https://api.github.com/users/fstrub95/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fstrub95/subscriptions","organizations_url":"https://api.github.com/users/fstrub95/orgs","repos_url":"https://api.github.com/users/fstrub95/repos","events_url":"https://api.github.com/users/fstrub95/events{/privacy}","received_events_url":"https://api.github.com/users/fstrub95/received_events","type":"User","site_admin":false},"created_at":"2015-10-29T13:45:13Z","updated_at":"2015-10-29T13:45:13Z","body":"Commit:\r\nhttps://github.com/fstrub95/nnsparse/commit/f23724f885e0ae6b4e27857dbdceaf6a257448be"}}