diff options
Diffstat (limited to 'contrib/lua-torch/nn/GatedLinearUnit.lua')
-rw-r--r-- | contrib/lua-torch/nn/GatedLinearUnit.lua | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/contrib/lua-torch/nn/GatedLinearUnit.lua b/contrib/lua-torch/nn/GatedLinearUnit.lua new file mode 100644 index 000000000..5273abfd4 --- /dev/null +++ b/contrib/lua-torch/nn/GatedLinearUnit.lua @@ -0,0 +1,27 @@ +local GatedLinearUnit, parent = torch.class('nn.GatedLinearUnit', 'nn.Module') + +function GatedLinearUnit:__init(dim) + parent.__init(self) + self.dim = dim +end + +function GatedLinearUnit:updateOutput(input) + local dim = self.dim or input:dim() + input.THNN.GatedLinear_updateOutput( + input:cdata(), + self.output:cdata(), + dim + ) + return self.output +end + +function GatedLinearUnit:updateGradInput(input, gradOutput) + local dim = self.dim or input:dim() + input.THNN.GatedLinear_updateGradInput( + input:cdata(), + gradOutput:cdata(), + self.gradInput:cdata(), + dim + ) + return self.gradInput +end |