HIT-SCIR / ELMoForManyLangs

Pre-trained ELMo Representations for Many Languages
MIT License
1.46k stars 244 forks source link

Error when importing elmofromanylans in my code #100

Open francoislievens opened 2 years ago

francoislievens commented 2 years ago

I have install the package in my anaconda env without problems.

When i use it in my python 3.8 code, at the line "from elmofromanylangs import Embedder"

i have the following error:

File "C:\Users\franc\.conda\envs\torch3\lib\site-packages\elmoformanylangs-0.0.4.post2-py3.8.egg\elmoformanylangs\__init__.py", line 2, in <module> from .elmo import Embedder File "C:\Users\franc\.conda\envs\torch3\lib\site-packages\elmoformanylangs-0.0.4.post2-py3.8.egg\elmoformanylangs\elmo.py", line 12, in <module> from .frontend import create_one_batch File "C:\Users\franc\.conda\envs\torch3\lib\site-packages\elmoformanylangs-0.0.4.post2-py3.8.egg\elmoformanylangs\frontend.py", line 10, in <module> from .modules.token_embedder import ConvTokenEmbedder, LstmTokenEmbedder File "C:\Users\franc\.conda\envs\torch3\lib\site-packages\elmoformanylangs-0.0.4.post2-py3.8.egg\elmoformanylangs\modules\token_embedder.py", line 8, in <module> from .highway import Highway File "C:\Users\franc\.conda\envs\torch3\lib\site-packages\elmoformanylangs-0.0.4.post2-py3.8.egg\elmoformanylangs\modules\highway.py", line 12, in <module> class Highway(torch.nn.Module): File "C:\Users\franc\.conda\envs\torch3\lib\site-packages\elmoformanylangs-0.0.4.post2-py3.8.egg\elmoformanylangs\modules\highway.py", line 47, in Highway def forward(self, inputs: torch.Tensor) -> torch.Tensor: # pylint: disable=arguments-differ File "C:\Users\franc\.conda\envs\torch3\lib\site-packages\overrides-6.1.0-py3.8.egg\overrides\overrides.py", line 88, in overrides return _overrides(method, check_signature, check_at_runtime) File "C:\Users\franc\.conda\envs\torch3\lib\site-packages\overrides-6.1.0-py3.8.egg\overrides\overrides.py", line 114, in _overrides _validate_method(method, super_class, check_signature) File "C:\Users\franc\.conda\envs\torch3\lib\site-packages\overrides-6.1.0-py3.8.egg\overrides\overrides.py", line 135, in _validate_method ensure_signature_is_compatible(super_method, method, is_static) File "C:\Users\franc\.conda\envs\torch3\lib\site-packages\overrides-6.1.0-py3.8.egg\overrides\signature.py", line 93, in ensure_signature_is_compatible ensure_return_type_compatibility(super_type_hints, sub_type_hints, method_name) File "C:\Users\franc\.conda\envs\torch3\lib\site-packages\overrides-6.1.0-py3.8.egg\overrides\signature.py", line 287, in ensure_return_type_compatibility raise TypeError( TypeError: Highway.forward: return type <class 'torch.Tensor'> is not a <class 'NoneType'>.

What can i do? Thanks a lot

rochanaph commented 2 years ago

Try this: pip uninstall overrides pip install overrides==3.1.0 I found it in stackoverflow and it worked for me. https://stackoverflow.com/a/67438055/4832492

iamanigeeit commented 3 months ago

The last working version of overrides is 4.1.2