Skip to content

Commit 8da1173

Browse files
committed
implement tostring for LSTM and VanillaRNN
1 parent 6e5e7ab commit 8da1173

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

LSTM.lua

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,3 +295,10 @@ function layer:accGradParameters(input, gradOutput, scale)
295295
end
296296
end
297297

298+
299+
function layer:__tostring__()
300+
local name = torch.type(self)
301+
local din, dout = self.input_dim, self.hidden_dim
302+
return string.format('%s(%d -> %d)', name, din, dout)
303+
end
304+

VanillaRNN.lua

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,3 +213,11 @@ function layer:clearState()
213213
self.grad_x:set()
214214
self.output:set()
215215
end
216+
217+
218+
function layer:__tostring__()
219+
local name = torch.type(self)
220+
local din, dout = self.input_dim, self.hidden_dim
221+
return string.format('%s(%d -> %d)', name, din, dout)
222+
end
223+

0 commit comments

Comments
 (0)