-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Nicholas Leonard
committed
Apr 18, 2017
1 parent
2238f86
commit 31b0b89
Showing
6 changed files
with
179 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
|
||
local LinearRNN, parent = torch.class("nn.LinearRNN", "nn.Recurrence") | ||
|
||
function LinearRNN:__init(inputsize, outputsize, transfer) | ||
transfer = transfer or nn.Sigmoid() | ||
local stepmodule = nn.Sequential() | ||
:add(nn.JoinTable(1,1)) | ||
:add(nn.Linear(inputsize+outputsize, outputsize)) | ||
:add(transfer) | ||
parent.__init(self, stepmodule, outputsize, 1) | ||
self.inputsize = inputsize | ||
self.outputsize = outputsize | ||
end | ||
|
||
function LinearRNN:__tostring__() | ||
return torch.type(self) .. "(" .. self.inputsize .. ", " .. self.outputsize ..")" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
local LookupRNN, parent = torch.class("nn.LookupRNN", "nn.Recurrence") | ||
|
||
function LookupRNN:__init(nindex, outputsize, transfer, merge) | ||
transfer = transfer or nn.Sigmoid() | ||
merge = merge or nn.CAddTable() | ||
local stepmodule = nn.Sequential() -- input is {x[t], h[t-1]} | ||
:add(nn.ParallelTable() | ||
:add(nn.LookupTable(nindex, outputsize)) -- input layer | ||
:add(nn.Linear(outputsize, outputsize))) -- recurrent layer | ||
:add(merge) | ||
:add(transfer) | ||
parent.__init(self, stepmodule, outputsize, 0) | ||
self.nindex = nindex | ||
self.outputsize = outputsize | ||
end | ||
|
||
function LookupRNN:maskZero() | ||
error"Not Implemented" | ||
end | ||
|
||
function LookupRNN:__tostring__() | ||
return torch.type(self) .. "(" .. self.nindex .. ", " .. self.outputsize ..")" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters