GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — rnn/Module.lua at master · Element-Research/rnn

Expand file tree

/

Module.lua

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
87 lines (77 loc) · 2.24 KB
/

Module.lua

Copy path

File metadata and controls

87 lines (77 loc) · 2.24 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
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
function Module:getHiddenState(step)
if self.modules then
local hiddenState = {}
for i, module in ipairs(self.modules) do
hiddenState[i] = module:getHiddenState(step)
end
return hiddenState
end
end
function Module:setHiddenState(step, hiddenState)
if self.modules then
assert(torch.type(hiddenState) == 'table')
for i, module in ipairs(self.modules) do
module:setHiddenState(step, hiddenState[i])
end
end
end
function Module:getGradHiddenState(step)
if self.modules then
local gradHiddenState = {}
for i, module in ipairs(self.modules) do
gradHiddenState[i] = module:getGradHiddenState(step)
end
return gradHiddenState
end
end
function Module:setGradHiddenState(step, gradHiddenState)
if self.modules then
assert(torch.type(gradHiddenState) == 'table')
for i, module in ipairs(self.modules) do
module:setGradHiddenState(step, gradHiddenState[i])
end
end
end
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.