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

AttributeError: 'TextMultiField' object has no attribute 'is_target' #493

Closed
tangxiangru opened this issue Jan 27, 2019 · 2 comments
Closed

Comments

@tangxiangru
Copy link

tangxiangru commented Jan 27, 2019

Traceback (most recent call last):
File "translate.py", line 42, in module
main(opt)
File "translate.py", line 27, in main
attn_debug=opt.attn_debug
File "/home/txr/OpenNMT-py-ende/onmt/translate/translator.py", line 208, in translate
for batch in data_iter:
File "/home/txr/anaconda3/envs/python3/lib/python3.5/site-packages/torchtext/data/iterator.py", line 157, in iter
yield Batch(minibatch, self.dataset, self.device)
File "/home/txr/anaconda3/envs/python3/lib/python3.5/site-packages/torchtext/data/batch.py", line 26, in init
self.input_fields = [k for k, v in dataset.fields.items() if
File "/home/txr/anaconda3/envs/python3/lib/python3.5/site-packages/torchtext/data/batch.py", line 27, in
v is not None and not v.is_target]
AttributeError: 'TextMultiField' object has no attribute 'is_target'

@mttk
Copy link
Contributor

mttk commented Jan 31, 2019

This bug has been fixed in master recently, and your code will work if you install torchtext from source. RawField, which TextMultiField inherits from, was missing the is_target attribute.

@mttk mttk closed this as completed Jan 31, 2019
@Fronkan
Copy link

Fronkan commented Mar 12, 2019

Just for everyone running on the currently latest version on pip, version 0.3.1, and won't or can't install from source here is a simple work around for the issue:

field = RawField()
field.is_target = False

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

3 participants