Skip to content

Commit

Permalink
fix issue 207
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholas-leonard committed Apr 21, 2016
1 parent 6a71750 commit 7116a3d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 2 additions & 2 deletions SeqLSTM.lua
Original file line number Diff line number Diff line change
Expand Up @@ -359,8 +359,8 @@ function SeqLSTM:accGradParameters(input, gradOutput, scale)
end

function SeqLSTM:forget()
self.c0:zero()
self.h0:zero()
self.c0:resize(0)
self.h0:resize(0)
end

-- Toggle to feed long sequences using multiple forwards.
Expand Down
11 changes: 11 additions & 0 deletions test/test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4898,6 +4898,17 @@ function rnntest.FastLSTM_issue203()
mytester:assert(err < 0.000001, "error "..err)
end

function rnntest.SeqLSTM_issue207()
local lstm = nn.SeqLSTM(10, 10)
lstm.batchfirst = true
lstm:remember('both')
lstm:training()
lstm:forward(torch.Tensor(32, 20, 10))
lstm:evaluate()
lstm:forget()
lstm:forward(torch.Tensor(1, 20, 10))
end

function rnn.test(tests, benchmark_)
mytester = torch.Tester()
benchmark = benchmark_
Expand Down

0 comments on commit 7116a3d

Please sign in to comment.