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:
authorSoumith Chintala <soumith@gmail.com>2015-08-15 08:41:31 +0300
committerSoumith Chintala <soumith@gmail.com>2015-08-15 08:41:31 +0300
commit5659715a11a38582f88bebb7a2736075d876ab20 (patch)
tree7ce5b1bc905a3931af7b29b5c51ebe0ce28d9675
parent14599d495549fc0b907dccdb44dc118723319dac (diff)
parent6be22054b4a825ade2985afd7e9e34c666b990d2 (diff)
Merge pull request #351 from clementfarabet/master
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