-
-
Save szagoruyko/5a85d194c0ed61e1a729 to your computer and use it in GitHub Desktop.
linear with no bias
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local Linear, parent = torch.class('nn.NoBiasLinear', 'nn.Linear') | |
function Linear:__init(inputSize, outputSize) | |
parent.__init(self, inputSize, outputSize) | |
self.bias:fill(0) | |
end | |
function Linear:accGradParameters(input, gradOutput, scale) | |
scale = scale or 1 | |
if input:dim() == 1 then | |
self.gradWeight:addr(scale, gradOutput, input) | |
elseif input:dim() == 2 then | |
self.gradWeight:addmm(scale, gradOutput:t(), input) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment