forked from clementfarabet/lua---nnx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Abs.lua
30 lines (25 loc) · 740 Bytes
/
Abs.lua
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
28
29
30
local Abs, parent = torch.class('nn.Abs', 'nn.Module')
function Abs:__init(args)
parent.__init(self)
if args then
error(xlua.usage('nn.Abs',
'a simple component-wise mapping: abs()',
'abs = nn.Abs()\n'..
'rectified = abs:forward(sometensor)',
{type='nil', help='no arg required'}))
end
end
function Abs:forward(input)
input.nn.Abs_forward(self, input)
return self.output
end
function Abs:backward(input, gradOutput)
input.nn.Abs_backward(self, input, gradOutput)
return self.gradInput
end
function Abs:write(file)
parent.write(self, file)
end
function Abs:read(file)
parent.read(self, file)
end