diff options
author | Soumith Chintala <soumith@gmail.com> | 2016-03-04 19:18:28 +0300 |
---|---|---|
committer | Soumith Chintala <soumith@gmail.com> | 2016-03-04 19:18:28 +0300 |
commit | b7f0133f2ea4fe4aadc3f737b36357f6a77f4701 (patch) | |
tree | 6db79a1cf8c4e5998f8ed6be1ce1a00062bda290 /Dropout.lua | |
parent | 1443e3ddbed58737dcba00db7b85ea005a2abc95 (diff) | |
parent | 06ff3228dfc4ae32eb2bb55b30ac39aec095e0db (diff) |
Merge pull request #688 from szagoruyko/dropout_fix
Fix direct assignment in AddConstant, Copy, Dropout, MulConstant
Diffstat (limited to 'Dropout.lua')
-rw-r--r-- | Dropout.lua | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/Dropout.lua b/Dropout.lua index dbb65f1..946c37f 100644 --- a/Dropout.lua +++ b/Dropout.lua @@ -15,7 +15,7 @@ end function Dropout:updateOutput(input) if self.inplace then - self.output = input + self.output:set(input) else self.output:resizeAs(input):copy(input) end @@ -35,21 +35,16 @@ function Dropout:updateOutput(input) end function Dropout:updateGradInput(input, gradOutput) + if self.inplace then + self.gradInput:set(gradOutput) + else + self.gradInput:resizeAs(gradOutput):copy(gradOutput) + end if self.train then - if self.inplace then - self.gradInput = gradOutput - else - self.gradInput:resizeAs(gradOutput):copy(gradOutput) - end if self.p > 0 then self.gradInput:cmul(self.noise) -- simply mask the gradients with the noise vector end else - if self.inplace then - self.gradInput = gradOutput - else - self.gradInput:resizeAs(gradOutput):copy(gradOutput) - end if not self.v2 and self.p > 0 then self.gradInput:mul(1-self.p) end |