Skip to content

Commit

Permalink
Forcing zeroing when self.output is resized (nn.Linear)
Browse files Browse the repository at this point in the history
  • Loading branch information
Clement Farabet committed Aug 15, 2015
1 parent 14599d4 commit 6be2205
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Linear.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6be2205

Please sign in to comment.