Cadene / skip-thoughts.torch

Porting of Skip-Thoughts pretrained models from Theano to PyTorch & Torch7
149 stars 19 forks source link

error when batchsize=1 #5

Open zengxianyu opened 6 years ago

zengxianyu commented 6 years ago

4

line 135 in skip-thoughts.torch/pytorch/skipthoughts/skipthoughts.py lengths = list(max_length - input.data.eq(0).sum(1).squeeze()) will raise an error if the batch size is 1, saying ``typeError: iteration over a 0-d tensor''

shenyedepisa commented 6 months ago

I also encountered this error. When the input dimension is (1, n), the result of max_length-input.data.eq(0).sum(1).squeeze() is a scalar, and list( ) will report an error of "typeError: iteration over a 0-d tensor ". I think your submission is correct. It solves the problem.