blob: 67af15a9805aec35d11b20b9738921bfcf7dba43 (
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
|
local SoftShrink, parent = torch.class('nn.SoftShrink', 'nn.Module')
function SoftShrink:__init(lam)
parent.__init(self)
self.lambda = lam or 0.5
end
function SoftShrink:updateOutput(input)
input.THNN.SoftShrink_updateOutput(
input:cdata(),
self.output:cdata(),
self.lambda
)
return self.output
end
function SoftShrink:updateGradInput(input, gradOutput)
input.THNN.SoftShrink_updateGradInput(
input:cdata(),
gradOutput:cdata(),
self.gradInput:cdata(),
self.lambda
)
return self.gradInput
end
|