THUNLP-MT / Mask-Align

Code for our paper "Mask-Align: Self-Supervised Neural Word Alignment" in ACL 2021
BSD 3-Clause "New" or "Revised" License
60 stars 20 forks source link

Issue with namespace using train.sh #7

Open gsarti opened 2 years ago

gsarti commented 2 years ago

Hi,

I'm trying to run the training script with Python 3.8.10 and torch==1.10.2+cu113, and I obtain the following error:

>> bash thualign/bin/train.sh -s mask_align -e agree_deen
running mask_align
Traceback (most recent call last):
  File "/net/aistaff/sarti/Mask-Align/thualign/bin/trainer.py", line 21, in <module>
    import thualign.data as data
  File "/net/aistaff/sarti/Mask-Align/thualign/data/__init__.py", line 5, in <module>
    from thualign.data.dataset import Dataset, TextLineDataset
  File "/net/aistaff/sarti/Mask-Align/thualign/data/dataset.py", line 51, in <module>
    class Dataset(IterableDataset):
  File "/net/aistaff/sarti/Mask-Align/venv/lib/python3.8/site-packages/torch/utils/data/_typing.py", line 273, in __new__
    return super().__new__(cls, name, bases, namespace, **kwargs)  # type: ignore[call-overload]
  File "/usr/lib/python3.8/abc.py", line 85, in __new__
    cls = super().__new__(mcls, name, bases, namespace, **kwargs)
  File "/net/aistaff/sarti/Mask-Align/venv/lib/python3.8/site-packages/torch/utils/data/_typing.py", line 373, in _dp_init_subclass
    raise TypeError("Expected 'Iterator' as the return annotation for `__iter__` of {}"
TypeError: Expected 'Iterator' as the return annotation for `__iter__` of Dataset, but found thualign.data.iterator.Iterator

Do you have a specific pinned version of torch to make the script work?

zhiqiangrao commented 2 years ago

I used Python 3.7 and pytorch 1.8.0

carboncoo commented 2 years ago

I used torch 1.7. I think it might be incompatible with torch>=1.9 as they introduced the torch/utils/data/_typing.py file.