harvardnlp / TextFlow

MIT License
116 stars 15 forks source link

`train` argument in MultipleOutputField.process needs to be removed? #5

Closed hyunjik11 closed 4 years ago

hyunjik11 commented 4 years ago

Here https://github.com/harvardnlp/TextFlow/blob/0eb8552ae5b370f69e440bca6c6c226b1734c1ba/utils.py#L43 there is a train argument that is unused. So when running on the polyphonic music data, this causes an error:

File ".../TextFlow/main.py", line 43, in run_epoch
    for i, batch in enumerate(iter(ds)):
  File ".../torchtext/data/iterator.py", line 156, in __iter__
    yield Batch(minibatch, self.dataset, self.device)
  File ".../torchtext/data/batch.py", line 34, in __init__
    setattr(self, name, field.process(batch, device=device))
TypeError: process() missing 1 required positional argument: 'train'

because the process method of the Field class in torchtext only has arguments batch and device - c.f. https://github.com/pytorch/text/blob/f765e517d6cc456b876715f1cb9c843bec8b14ed/torchtext/data/field.py#L225

It runs without error when the train argument is removed.

zackziegler95 commented 4 years ago

This is a torchtext version issue. Please use the versions listed in the README if you want everything to run!

hyunjik11 commented 4 years ago

I see, I was indeed using the latest torchtext v0.4.0 as opposed to v0.2.3 used for this repository. If people want to use v0.4.0, I think the above is the only change that needs to be made.