Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RuntimeError occurs running integration_test.py #169

Open
jhyun0919 opened this issue Sep 24, 2018 · 1 comment
Open

RuntimeError occurs running integration_test.py #169

jhyun0919 opened this issue Sep 24, 2018 · 1 comment

Comments

@jhyun0919
Copy link

RuntimeError occurs when I run python script integration_test.py.

I did not modify any code, just installed pytorch-seq2seq and ran the script.

Trying to find out how to run the script without error...
Please comment what is wrong in my work.

The result is attached below.

Traceback (most recent call last):
  File "scripts/integration_test.py", line 115, in <module>
    seq = predictor.predict(inp_seq.split())
  File "build/bdist.linux-x86_64/egg/seq2seq/evaluator/predictor.py", line 44, in predict
  File "build/bdist.linux-x86_64/egg/seq2seq/evaluator/predictor.py", line 30, in get_decoder_features
  File "/root/deep_rl_regex/local/lib/python2.7/site-packages/torch/nn/modules/module.py", line 491, in __call__
    result = self.forward(*input, **kwargs)
  File "build/bdist.linux-x86_64/egg/seq2seq/models/seq2seq.py", line 53, in forward
  File "/root/deep_rl_regex/local/lib/python2.7/site-packages/torch/nn/modules/module.py", line 491, in __call__
    result = self.forward(*input, **kwargs)
  File "build/bdist.linux-x86_64/egg/seq2seq/models/TopKDecoder.py", line 131, in forward
  File "build/bdist.linux-x86_64/egg/seq2seq/models/DecoderRNN.py", line 96, in forward_step
  File "/root/deep_rl_regex/local/lib/python2.7/site-packages/torch/nn/modules/module.py", line 491, in __call__
    result = self.forward(*input, **kwargs)
  File "/root/deep_rl_regex/local/lib/python2.7/site-packages/torch/nn/modules/sparse.py", line 108, in forward
    self.norm_type, self.scale_grad_by_freq, self.sparse)
  File "/root/deep_rl_regex/local/lib/python2.7/site-packages/torch/nn/functional.py", line 1076, in embedding
    return torch.embedding(weight, input, padding_idx, scale_grad_by_freq, sparse)
RuntimeError: Expected object of type torch.cuda.LongTensor but found type torch.LongTensor for argument #3 'index'
2018-09-24 09:41:23,263 root         INFO     Namespace(dev_path='data/toy_reverse/dev/data.txt', expt_dir='./experiment', load_checkpoint=None, log_level='info', resume=True, train_path='data/toy_reverse/train/data.txt')
2018-09-24 09:41:28,122 seq2seq.trainer.supervised_trainer INFO     Optimizer: Adam (
Parameter Group 0
    amsgrad: False
    betas: (0.9, 0.999)
    eps: 1e-08
    lr: 0.001
    weight_decay: 0
), Scheduler: None
/root/deep_rl_regex/local/lib/python2.7/site-packages/torchtext/data/field.py:321: UserWarning: volatile was removed and now has no effect. Use `with torch.no_grad():` instead.
  return Variable(arr, volatile=not train), lengths
/root/deep_rl_regex/local/lib/python2.7/site-packages/torchtext/data/field.py:322: UserWarning: volatile was removed and now has no effect. Use `with torch.no_grad():` instead.
  return Variable(arr, volatile=not train)
Traceback (most recent call last):
  File "scripts/integration_test.py", line 115, in <module>
    seq = predictor.predict(inp_seq.split())
  File "build/bdist.linux-x86_64/egg/seq2seq/evaluator/predictor.py", line 44, in predict
  File "build/bdist.linux-x86_64/egg/seq2seq/evaluator/predictor.py", line 30, in get_decoder_features
  File "/root/deep_rl_regex/local/lib/python2.7/site-packages/torch/nn/modules/module.py", line 491, in __call__
    result = self.forward(*input, **kwargs)
  File "build/bdist.linux-x86_64/egg/seq2seq/models/seq2seq.py", line 53, in forward
  File "/root/deep_rl_regex/local/lib/python2.7/site-packages/torch/nn/modules/module.py", line 491, in __call__
    result = self.forward(*input, **kwargs)
  File "build/bdist.linux-x86_64/egg/seq2seq/models/TopKDecoder.py", line 131, in forward
  File "build/bdist.linux-x86_64/egg/seq2seq/models/DecoderRNN.py", line 96, in forward_step
  File "/root/deep_rl_regex/local/lib/python2.7/site-packages/torch/nn/modules/module.py", line 491, in __call__
    result = self.forward(*input, **kwargs)
  File "/root/deep_rl_regex/local/lib/python2.7/site-packages/torch/nn/modules/sparse.py", line 108, in forward
    self.norm_type, self.scale_grad_by_freq, self.sparse)
  File "/root/deep_rl_regex/local/lib/python2.7/site-packages/torch/nn/functional.py", line 1076, in embedding
    return torch.embedding(weight, input, padding_idx, scale_grad_by_freq, sparse)
RuntimeError: Expected object of type torch.cuda.LongTensor but found type torch.LongTensor for argument #3 'index'
2018-09-24 09:41:29,348 root         INFO     Namespace(dev_path='data/toy_reverse/dev/data.txt', expt_dir='./experiment', load_checkpoint='2018_09_24_09_41_21', log_level='info', resume=False, train_path='data/toy_reverse/train/data.txt')
2018-09-24 09:41:33,669 root         INFO     loading checkpoint from ./experiment/checkpoints/2018_09_24_09_41_21
/root/deep_rl_regex/local/lib/python2.7/site-packages/torchtext/data/field.py:321: UserWarning: volatile was removed and now has no effect. Use `with torch.no_grad():` instead.
  return Variable(arr, volatile=not train), lengths
/root/deep_rl_regex/local/lib/python2.7/site-packages/torchtext/data/field.py:322: UserWarning: volatile was removed and now has no effect. Use `with torch.no_grad():` instead.
  return Variable(arr, volatile=not train)
Traceback (most recent call last):
  File "scripts/integration_test.py", line 115, in <module>
    seq = predictor.predict(inp_seq.split())
  File "build/bdist.linux-x86_64/egg/seq2seq/evaluator/predictor.py", line 44, in predict
  File "build/bdist.linux-x86_64/egg/seq2seq/evaluator/predictor.py", line 30, in get_decoder_features
  File "/root/deep_rl_regex/local/lib/python2.7/site-packages/torch/nn/modules/module.py", line 491, in __call__
    result = self.forward(*input, **kwargs)
  File "build/bdist.linux-x86_64/egg/seq2seq/models/seq2seq.py", line 53, in forward
  File "/root/deep_rl_regex/local/lib/python2.7/site-packages/torch/nn/modules/module.py", line 491, in __call__
    result = self.forward(*input, **kwargs)
  File "build/bdist.linux-x86_64/egg/seq2seq/models/TopKDecoder.py", line 131, in forward
  File "build/bdist.linux-x86_64/egg/seq2seq/models/DecoderRNN.py", line 96, in forward_step
  File "/root/deep_rl_regex/local/lib/python2.7/site-packages/torch/nn/modules/module.py", line 491, in __call__
    result = self.forward(*input, **kwargs)
  File "/root/deep_rl_regex/local/lib/python2.7/site-packages/torch/nn/modules/sparse.py", line 108, in forward
    self.norm_type, self.scale_grad_by_freq, self.sparse)
  File "/root/deep_rl_regex/local/lib/python2.7/site-packages/torch/nn/functional.py", line 1076, in embedding
    return torch.embedding(weight, input, padding_idx, scale_grad_by_freq, sparse)
RuntimeError: Expected object of type torch.cuda.LongTensor but found type torch.LongTensor for argument #3 'index'
@pskrunner14
Copy link

@jhyun0919 it'll be fixed in next alpha release. Please see #161.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants