seq2seq_parser icon indicating copy to clipboard operation
seq2seq_parser copied to clipboard

RuntimeError: generator raised StopIteration

Open tysonyuu opened this issue 7 years ago • 6 comments

Hello, I tried to use my dataset to train the model. I've preprocessed my data and made my pretrain embedding. So far, I only use my pretrain embedding and POS as my input feature. However, at the end of the training of the first epoch, I am faced with this problem. Did I make any mistakes? Do you have any idea that can help me solve this problem? Thank you!


Start training...

  • number of epochs: 13, starting from Epoch 1
  • batch size: 64

Loading train dataset from data/temp/dp/dp.train.1.pt, number of examples: 56957 Epoch 1, 50/ 890; acc: 0.00; ppl: 13.31; xent: 2.59; 9483 src tok/s; 11083 tgt tok/s; 2 s elapsed Epoch 1, 100/ 890; acc: 0.00; ppl: 6.80; xent: 1.92; 9531 src tok/s; 11131 tgt tok/s; 5 s elapsed Epoch 1, 150/ 890; acc: 0.00; ppl: 4.72; xent: 1.55; 8883 src tok/s; 10483 tgt tok/s; 7 s elapsed Epoch 1, 200/ 890; acc: 0.00; ppl: 4.09; xent: 1.41; 9957 src tok/s; 11557 tgt tok/s; 9 s elapsed Epoch 1, 250/ 890; acc: 0.00; ppl: 3.56; xent: 1.27; 9382 src tok/s; 10982 tgt tok/s; 11 s elapsed Epoch 1, 300/ 890; acc: 0.00; ppl: 3.84; xent: 1.35; 9654 src tok/s; 11254 tgt tok/s; 14 s elapsed Epoch 1, 350/ 890; acc: 0.00; ppl: 3.16; xent: 1.15; 9321 src tok/s; 10921 tgt tok/s; 16 s elapsed Epoch 1, 400/ 890; acc: 0.00; ppl: 3.60; xent: 1.28; 9917 src tok/s; 11517 tgt tok/s; 18 s elapsed Epoch 1, 450/ 890; acc: 0.00; ppl: 3.24; xent: 1.17; 9728 src tok/s; 11328 tgt tok/s; 20 s elapsed Epoch 1, 500/ 890; acc: 0.00; ppl: 2.87; xent: 1.06; 9012 src tok/s; 10612 tgt tok/s; 22 s elapsed Epoch 1, 550/ 890; acc: 0.00; ppl: 3.04; xent: 1.11; 9461 src tok/s; 11061 tgt tok/s; 25 s elapsed Epoch 1, 600/ 890; acc: 0.00; ppl: 2.79; xent: 1.03; 9510 src tok/s; 11110 tgt tok/s; 27 s elapsed Epoch 1, 650/ 890; acc: 0.00; ppl: 2.68; xent: 0.99; 10310 src tok/s; 11910 tgt tok/s; 29 s elapsed Epoch 1, 700/ 890; acc: 0.00; ppl: 2.33; xent: 0.85; 8729 src tok/s; 10329 tgt tok/s; 31 s elapsed Epoch 1, 750/ 890; acc: 0.00; ppl: 2.36; xent: 0.86; 9449 src tok/s; 11049 tgt tok/s; 34 s elapsed Epoch 1, 800/ 890; acc: 0.00; ppl: 2.32; xent: 0.84; 9400 src tok/s; 11000 tgt tok/s; 36 s elapsed Epoch 1, 850/ 890; acc: 0.00; ppl: 1.97; xent: 0.68; 8381 src tok/s; 9981 tgt tok/s; 38 s elapsed Traceback (most recent call last): File "/usr/lib/python3.7/site-packages/torchtext/data/iterator.py", line 182, in iter raise StopIteration StopIteration

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "train.py", line 506, in main() File "train.py", line 498, in main train_model(model, fields, optim, data_type, model_opt) File "train.py", line 260, in train_model train_stats = trainer.train(train_iter, epoch, report_func) File "/home/tyson/seq2seq_parser/onmt/Trainer.py", line 171, in train for i, batch in enumerate(train_iter): File "train.py", line 144, in iter for batch in self.cur_iter: RuntimeError: generator raised StopIteration


tysonyuu avatar Dec 06 '18 11:12 tysonyuu

It seems that the problem is due to python3.7. After changing to python3.6, I can run the code.

However, I have another question.
Did you check "acyclic" and "projective" in your beam search, since when I traced back to onmt/translate/Beam.py, I didn't find that. Besides, (-constraint_length 8 -alpha_c 0.8 -alpha_p 0.8 )aren't recognized arguments in your code.


$ python3.6 translate.py -model data/model/dp/dp_acc_0.00_ppl_1.30_e6.pt -src data/input/dp/src_ptb_sd_test.input -tgt data/input/dp/tgt_ptb_sd_test.input -output data/results/dp/tgt_ptb_sd_test.pred -replace_unk -verbose -gpu 0 -beam_size 64 -constraint_length 8 -alpha_c 0.8 -alpha_p 0.8 usage: translate.py [-h] [-md] -model MODEL [-data_type DATA_TYPE] -src SRC [-src_dir SRC_DIR] [-tgt TGT] [-output OUTPUT] [-report_bleu] [-report_rouge] [-dynamic_dict] [-share_vocab] [-beam_size BEAM_SIZE] [-min_length MIN_LENGTH] [-max_length MAX_LENGTH] [-max_sent_length] [-stepwise_penalty] [-length_penalty {none,wu,avg}] [-coverage_penalty {none,wu,summary}] [-alpha ALPHA] [-beta BETA] [-block_ngram_repeat BLOCK_NGRAM_REPEAT] [-ignore_when_blocking IGNORE_WHEN_BLOCKING [IGNORE_WHEN_BLOCKING ...]] [-replace_unk] [-verbose] [-attn_debug] [-dump_beam DUMP_BEAM] [-n_best N_BEST] [-batch_size BATCH_SIZE] [-gpu GPU] [-sample_rate SAMPLE_RATE] [-window_size WINDOW_SIZE] [-window_stride WINDOW_STRIDE] [-window WINDOW] translate.py: error: unrecognized arguments: -constraint_length 8 -alpha_c 0.8 -alpha_p 0.8

tysonyuu avatar Dec 09 '18 15:12 tysonyuu

Sorry about the early version I have uploaded, I will publish the latest version soon.

bcmi220 avatar Dec 10 '18 03:12 bcmi220

Thank you very much !! Does the current version only release the part that helps us find the head of every word? The part that using BiLSTM-CRF to find dependency relation hasn't released yet?

tysonyuu avatar Dec 10 '18 04:12 tysonyuu

I also confronted the some issues:

Cannot find "acyclic" and "projective" in your beam search, since when I traced back to onmt/translate/Beam.py, I didn't find that. Besides, (-constraint_length 8 -alpha_c 0.8 -alpha_p 0.8 )aren't recognized arguments in your code.

Can you help me with this?

terrance-up avatar May 07 '20 06:05 terrance-up

Hello, thank you for using this repo. The beam search code is ignored since the last upload, and need some time to find the old code. But you could ignore these two parameters first for rough evaluation. May this will help you.

bcmi220 avatar May 07 '20 09:05 bcmi220

Thank you. Already try it. Work fine. Is the tree constraint Beam search something like rules to decease the score of the node with acyclic or projective featuers?

terrance-up avatar May 07 '20 10:05 terrance-up