Skip to content

Commit

Permalink
fixed to newer torch7
Browse files Browse the repository at this point in the history
  • Loading branch information
ketranm committed Jan 31, 2019
1 parent 9b1e56c commit 7ba85fb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 3 additions & 0 deletions Emission.lua
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ function model:log_prob(input)
self._logp = self._cache
end

if input:type() == 'torch.IntTensor' then
input = input:long()
end
return self._logp:index(2, input:view(-1)):view(-1, N, T):transpose(1, 2):transpose(2, 3)
end

Expand Down
5 changes: 3 additions & 2 deletions main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,9 @@ function infer(textfile, predfile, modelfile)
local x = sents[k+i]
input[{{k+1}, {1, x:numel()}}] = x
end

input = input:cuda()
if opt.cuda then
input = input:cuda()
end
io.write(string.format('sent: %d\r', i))
io.flush()
local log_prior = prior_net:log_prob(input)
Expand Down

0 comments on commit 7ba85fb

Please sign in to comment.