- Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathFunctionWrapper.lua
More file actions
Latest commit
22 lines (18 loc) · 648 Bytes
/
Copy pathFunctionWrapper.lua
File metadata and controls
22 lines (18 loc) · 648 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
require'nnx'
localFunctionWrapper, parent=torch.class('nn.FunctionWrapper', 'nn.Module')
localhelp_desc=[[
Dummy module that takes a forward and a backward function as argument.
]]
functionFunctionWrapper:__init(init, updateOutput, updateGradInput)
init(self)
self.fn_updateOutput=updateOutput
self.fn_updateGradInput=updateGradInput
end
functionFunctionWrapper:updateOutput(input)
self.output=self.fn_updateOutput(self, input)
returnself.output
end
functionFunctionWrapper:updateGradInput(input, gradOutput)
self.gradInput=self.fn_updateGradInput(self, input, gradOutput)
returnself.gradInput
end