macournoyer / neuralconvo

Neural conversational model in Torch
777 stars 346 forks source link

Invalid arguments: DoubleTensor number FloatTensor #52

Closed julien-c closed 8 years ago

julien-c commented 8 years ago

I'm moderately convinced that this is a neuralconvo issue per se, but in case it is:

/root/torch/install/share/lua/5.1/optim/adam.lua:59: invalid arguments: DoubleTensor number FloatTensor 
expected arguments: *DoubleTensor* [DoubleTensor] double | *DoubleTensor* [DoubleTensor] [double] DoubleTensor
stack traceback:
    [C]: in function 'add'
    /root/torch/install/share/lua/5.1/optim/adam.lua:59: in function 'adam'
    train.lua:131: in main chunk
    [C]: in function 'dofile'
    /root/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:145: in main chunk
    [C]: at 0x00405d50

Any idea?

zhaopku commented 8 years ago

I have the same problem. Did you train this on CPU? I think this may be a problem of CPU/GPU converting, the author wrote the codes for GPU but didn't adjust well for CPU. Have a look at this link: sample.lua fails to run: error in function addmm()

zhaopku commented 8 years ago

Problem solved! Add this function to seq2seq.lua:

-- function Seq2Seq:double()
-- created by zhaopku to fix the problem of CPU mode
function Seq2Seq:double()
  self.encoder:double()
  self.decoder:double()

  if self.criterion then
    self.criterion:double()
  end
end

Then in train.lua:

at line 161: change model:float() to model:double()

macournoyer commented 8 years ago

Thx @zhaopku !

julien-c commented 8 years ago

Thanks guys! Would it make sense to merge this to the codebase?

hyeonseok92 commented 8 years ago

Thanks! It works for me!

gravitymonkey commented 7 years ago

Thanks, also works for me. Makes sense to merge (why not?)

paularmand commented 7 years ago

yes, working here too. +1 for merge