skip-thoughts.torch icon indicating copy to clipboard operation
skip-thoughts.torch copied to clipboard

error when batchsize=1

Open zengxianyu opened this issue 6 years ago • 1 comments

#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''

zengxianyu avatar Jun 28 '18 03:06 zengxianyu

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.

shenyedepisa avatar Mar 03 '24 21:03 shenyedepisa