From 6be22054b4a825ade2985afd7e9e34c666b990d2 Mon Sep 17 00:00:00 2001 From: Clement Farabet Date: Fri, 14 Aug 2015 23:21:25 -0400 Subject: [PATCH] Forcing zeroing when self.output is resized (nn.Linear) --- Linear.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Linear.lua b/Linear.lua index 31980bc06..7f6810d8d 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