diff options
author | Ivo Danihelka <ivo@danihelka.net> | 2013-07-17 22:57:19 +0400 |
---|---|---|
committer | Ivo Danihelka <ivo@danihelka.net> | 2013-07-17 22:57:19 +0400 |
commit | c82d86ba20172a869576f4cfb9a973437079f2e9 (patch) | |
tree | c7f8635e5b61a9877422d4f91b50af4ae36cea60 | |
parent | 313e69ce5adb6f45b37611d13ae556dfd4c071e5 (diff) |
Clarified the meaning of innode.data.gradOutput.
-rw-r--r-- | gmodule.lua | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/gmodule.lua b/gmodule.lua index 0510a11..283cdd5 100644 --- a/gmodule.lua +++ b/gmodule.lua @@ -263,23 +263,23 @@ function gModule:updateGradInput(input,gradOutput) end -- now fix the order of gradInput + -- The innode is used as the input by all the input nodes. + -- The data.gradOutput holds the gradients to-be-summed. + -- Here, instead of summing them, we reorder them based on the mapindex. self.gradInput = self.innode.data.gradOutput - if not istable(self.gradInput) then - return self.gradInput - end local gi = {} for i,child in ipairs(self.innode.children) do local mi = self.innode.data.mapindex[child.data] table.insert(gi,self.gradInput[mi]) end - while istable(self.gradInput) and #self.gradInput > 0 do + while #self.gradInput > 0 do table.remove(self.gradInput) end for i,v in ipairs(gi) do table.insert(self.gradInput,v) end - if #self.innode.children == 1 and self.gradInput == self.innode.data.gradOutput then + if #self.innode.children == 1 then self.gradInput = self.gradInput[1] end |