Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python2 iterator bug? #109

Closed
tombosc opened this issue Sep 7, 2017 · 3 comments
Closed

python2 iterator bug? #109

tombosc opened this issue Sep 7, 2017 · 3 comments

Comments

@tombosc
Copy link

tombosc commented Sep 7, 2017

here is the snippet:

from __future__ import print_function
from torchtext.datasets import WikiText2

i_train, i_dev, i_test = WikiText2.iters(device='-1', root="data/")
for i in i_train:
    print(i)

here's the error:

Traceback (most recent call last):
  File "bug.py", line 5, in <module>
    for i in i_train:
  File "/u/bosctom/.local/lib/python2.7/site-packages/torchtext/data/iterator.py", line 218, in __iter__
    self.batch_size - len(text)))
TypeError: can't multiply sequence by non-int of type 'float'

The bug is related to python2's math.ceil() returning a float?

@nelson-liu
Copy link
Contributor

what version of torchtext are you using? A git hash would be nice, if you have one (or did you install from pip)? I get a different error related to the WikiText2 dataset not being updated to use the latest Vocab API on Python 2 and 3.

@tombosc
Copy link
Author

tombosc commented Sep 7, 2017

I got that error using the pip version: 0.1.1

@nelson-liu
Copy link
Contributor

yes, you're right --- there needs to be an int call at

text = text + ([TEXT.pad_token] * (math.ceil(len(text) / self.batch_size) *
. Would you be willing to create a PR, or should i go ahead?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants