donglixp / coarse2fine

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

error in decoding with small batch sizes

prezaei85 opened this issue · comments

I got the following error for batch size 5 and lower. I am trynig to use this for batch_size = 1 and I got the same thing. Any idea why?

python evaluate.py -model_path ../pretrained/pretrain.pt -batch_size 4
Evaluating model on the test set.
Loading model
Traceback (most recent call last):
  File "evaluate.py", line 89, in <module>
    main()
  File "evaluate.py", line 65, in main
    for batch in test_data:
  File "/home/ubuntu/anaconda3/envs/pytorch_p36_copy/lib/python3.6/site-packages/torchtext/data/iterator.py", line 151, in __iter__
    self.train)
  File "/home/ubuntu/anaconda3/envs/pytorch_p36_copy/lib/python3.6/site-packages/torchtext/data/batch.py", line 27, in __init__
    setattr(self, name, field.process(batch, device=device, train=train))
  File "/home/ubuntu/anaconda3/envs/pytorch_p36_copy/lib/python3.6/site-packages/torchtext/data/field.py", line 188, in process
    tensor = self.numericalize(padded, device=device, train=train)
  File "/home/ubuntu/anaconda3/envs/pytorch_p36_copy/lib/python3.6/site-packages/torchtext/data/field.py", line 310, in numericalize
    arr = self.tensor_type(arr)
RuntimeError: given sequence has an invalid size of dimension 2: 0


There are some 0 len layouts
Add this to evaluate:

js_list = [js for js in js_list if len(js['lay']) > 0]