forked from Element-Research/rnn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathModule.lua
49 lines (43 loc) · 1.26 KB
/
Module.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
local Module = nn.Module
-- You can use this to manually forget past memories in AbstractRecurrent instances
function Module:forget()
if self.modules then
for i,module in ipairs(self.modules) do
module:forget()
end
end
return self
end
-- Used by nn.Sequencers
function Module:remember(remember)
if self.modules then
for i, module in ipairs(self.modules) do
module:remember(remember)
end
end
return self
end
function Module:stepClone(shareParams, shareGradParams)
return self:sharedClone(shareParams, shareGradParams, true)
end
function Module:backwardOnline()
print("Deprecated Jan 6, 2016. By default rnn now uses backwardOnline, so no need to call this method")
end
-- calls setOutputStep on all component AbstractRecurrent modules
-- used by Recursor() after calling stepClone.
-- this solves a very annoying bug...
function Module:setOutputStep(step)
if self.modules then
for i,module in ipairs(self.modules) do
module:setOutputStep(step)
end
end
end
-- set the maximum number of backpropagation through time (BPTT) time-steps
function Module:maxBPTTstep(rho)
if self.modules then
for i, module in ipairs(self.modules) do
module:maxBPTTstep(rho)
end
end
end