Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/torch/nn.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClement Farabet <cfarabet@twitter.com>2015-08-15 06:21:25 +0300
committerClement Farabet <cfarabet@twitter.com>2015-08-15 06:21:25 +0300
commit6be22054b4a825ade2985afd7e9e34c666b990d2 (patch)
tree7ce5b1bc905a3931af7b29b5c51ebe0ce28d9675
parent14599d495549fc0b907dccdb44dc118723319dac (diff)
Forcing zeroing when self.output is resized (nn.Linear)
-rw-r--r--Linear.lua4
1 files changed, 4 insertions, 0 deletions
diff --git a/Linear.lua b/Linear.lua
index 31980bc..7f6810d 100644
--- a/Linear.lua
+++ b/Linear.lua
@@ -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