facebookresearch / fairseq

Facebook AI Research Sequence-to-Sequence Toolkit written in Python.
MIT License
30.43k stars 6.4k forks source link

Latest Version AssertionError #110

Closed wangyirui closed 6 years ago

wangyirui commented 6 years ago

I just cloned the lasted version (which claimed has fixed the round bug reported before). But I meet a new error: File "/home/kimi/Desktop/fairseq-py/fairseq/utils.py", line 292, in convert_padding_direction assert not isinstance(src_tokens, Variable) AssertionError

edunov commented 6 years ago

Are you training an LSTM model? Can you paste the entire log and the command you're running, please

wangyirui commented 6 years ago

Yes. I am using LSTM (lstm_luong_wmt_en_de). And my PyTorch is 0.4.0. (I use the same command in the previous versions (cloned 3 or 4 days ago) The command I use is: CUDA_VISIBLE_DEVICES=0 python train.py data-bin/wmt18.tokenized.de-en --source-lang de --target-lang en --optimizer adam --lr 1e-3 --clip-norm 5.0 --arch lstm_luong_wmt_en_de --save-dir checkpoints/blstm

The log is: | [de] dictionary: 8791 types | [en] dictionary: 6655 types | data-bin/wmt18.tokenized.de-en train 259668 examples | data-bin/wmt18.tokenized.de-en valid 11813 examples | model lstm_luong_wmt_en_de, criterion CrossEntropyCriterion | num. model params: 93171655 | training on 1 GPUs | max tokens per GPU = 6000 and max sentences per GPU = None | epoch 001: 0%| | 0/1694 [00:00<?, ?it/s]Traceback (most recent call last): File "train.py", line 29, in main(args) File "train.py", line 23, in main singleprocess_main(args) File "/home/kimi/Desktop/fairseq-py/singleprocess_train.py", line 79, in main train(args, trainer, dataset, epoch, batch_offset) File "/home/kimi/Desktop/fairseq-py/singleprocess_train.py", line 138, in train log_output = trainer.train_step(sample) File "/home/kimi/Desktop/fairseq-py/fairseq/trainer.py", line 94, in train_step loss, sample_sizes, logging_outputs, ooms_fwd = self._forward(sample) File "/home/kimi/Desktop/fairseq-py/fairseq/trainer.py", line 142, in _forward loss, sample_size, loggingoutput = self.criterion(self.model, sample) File "/home/kimi/anaconda2/envs/py36/lib/python3.6/site-packages/torch/nn/modules/module.py", line 357, in call result = self.forward(input, kwargs) File "/home/kimi/Desktop/fairseq-py/fairseq/criterions/cross_entropy.py", line 28, in forward net_output = model(sample['net_input']) File "/home/kimi/anaconda2/envs/py36/lib/python3.6/site-packages/torch/nn/modules/module.py", line 357, in call result = self.forward(input, *kwargs) File "/home/kimi/Desktop/fairseq-py/fairseq/models/fairseq_model.py", line 43, in forward encoder_out = self.encoder(src_tokens, src_lengths) File "/home/kimi/anaconda2/envs/py36/lib/python3.6/site-packages/torch/nn/modules/module.py", line 357, in call result = self.forward(input, **kwargs) File "/home/kimi/Desktop/fairseq-py/fairseq/models/lstm.py", line 103, in forward left_to_right=True, File "/home/kimi/Desktop/fairseq-py/fairseq/utils.py", line 292, in convert_padding_direction assert not isinstance(src_tokens, Variable) AssertionError

myleott commented 6 years ago

Yep, there was a change in behavior in the latest PyTorch:

>>> x = torch.autograd.Variable(torch.rand(5))
>>> isinstance(x, torch.autograd.Variable)
True
>>> isinstance(x.data, torch.autograd.Variable)
True

I'll submit a fix shortly.