blob: 5273abfd4438958b1643108957612a8da7705e15 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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
|