Skip to content

Commit

Permalink
forward training and evaluate methods to net in LanguageModel to prop…
Browse files Browse the repository at this point in the history
…erly handle dropout
  • Loading branch information
jcjohnson committed Mar 16, 2016
1 parent cd8d0bc commit b77a8b7
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion LanguageModel.lua
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,18 @@ function LM:parameters()
end


function LM:training()
self.net:training()
parent.evaluate(self)
end


function LM:evaluate()
self.net:evaluate()
parent.evaluate(self)
end


function LM:resetStates()
for i, rnn in ipairs(self.rnns) do
rnn:resetStates()
Expand Down Expand Up @@ -173,9 +185,10 @@ function LM:sample(kwargs)
first_t = 1
end

local _, next_char = nil, nil
for t = first_t, T do
if sample == 0 then
local _, next_char = scores:max(3)
_, next_char = scores:max(3)
next_char = next_char[{{}, {}, 1}]
else
local probs = torch.div(scores, temperature):double():exp():squeeze()
Expand Down

0 comments on commit b77a8b7

Please sign in to comment.