diff options
author | Clement Farabet <cfarabet@twitter.com> | 2015-08-15 06:21:25 +0300 |
---|---|---|
committer | Clement Farabet <cfarabet@twitter.com> | 2015-08-15 06:21:25 +0300 |
commit | 6be22054b4a825ade2985afd7e9e34c666b990d2 (patch) | |
tree | 7ce5b1bc905a3931af7b29b5c51ebe0ce28d9675 | |
parent | 14599d495549fc0b907dccdb44dc118723319dac (diff) |
Forcing zeroing when self.output is resized (nn.Linear)
-rw-r--r-- | Linear.lua | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -39,7 +39,11 @@ function Linear:updateOutput(input) self.output:addmv(1, self.weight, input) elseif input:dim() == 2 then local nframe = input:size(1) + local nElement = self.output:nElement() self.output:resize(nframe, self.bias:size(1)) + if self.output:nElement() ~= nElement then + self.output:zero() + end if not self.addBuffer or self.addBuffer:nElement() ~= nframe then self.addBuffer = input.new(nframe):fill(1) end |