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

from elmoformanylangs import Embedder #95

Closed
Nitasophia opened this issue Apr 30, 2021 · 9 comments
Closed

from elmoformanylangs import Embedder #95

Nitasophia opened this issue Apr 30, 2021 · 9 comments

Comments

@Nitasophia
Copy link

from elmoformanylangs import Embedder

in this line, i got error like this

TypeError: Highway.forward: input must be present

Can anyone help me?

@paleboot
Copy link

paleboot commented May 3, 2021

Can produce a similar error, here's the traceback:

import ELMoForManyLangs.elmoformanylangs as elmo

/content/ELMoForManyLangs/elmoformanylangs/modules/highway.py in Highway()
     45 
     46     @overrides
---> 47     def forward(self, inputs: torch.Tensor) -> torch.Tensor:  # pylint: disable=arguments-differ
     48         current_input = inputs
     49         for layer in self._layers:

/usr/local/lib/python3.7/dist-packages/overrides/overrides.py in overrides(method, check_signature, check_at_runtime)
     86     """
     87     if method is not None:
---> 88         return _overrides(method, check_signature, check_at_runtime)
     89     else:
     90         return functools.partial(

/usr/local/lib/python3.7/dist-packages/overrides/overrides.py in _overrides(method, check_signature, check_at_runtime)
    112                 return wrapper  # type: ignore
    113             else:
--> 114                 _validate_method(method, super_class, check_signature)
    115                 return method
    116     raise TypeError(f"{method.__qualname__}: No super class method found")
    
   /usr/local/lib/python3.7/dist-packages/overrides/overrides.py in _validate_method(method, super_class, check_signature)
    133         and not isinstance(super_method, property)
    134     ):
--> 135         ensure_signature_is_compatible(super_method, method, is_static)
    136 
    137 

/usr/local/lib/python3.7/dist-packages/overrides/signature.py in ensure_signature_is_compatible(super_callable, sub_callable, is_static)
     80 
     81     if super_type_hints is not None and sub_type_hints is not None:
---> 82         ensure_return_type_compatibility(super_type_hints, sub_type_hints, method_name)
     83         ensure_all_kwargs_defined_in_sub(
     84             super_sig, sub_sig, super_type_hints, sub_type_hints, is_static, method_name

/usr/local/lib/python3.7/dist-packages/overrides/signature.py in ensure_return_type_compatibility(super_type_hints, sub_type_hints, method_name)
    264     if not _issubtype(sub_return, super_return) and super_return is not None:
    265         raise TypeError(
--> 266             f"{method_name}: return type `{sub_return}` is not a `{super_return}`."
    267         )

TypeError: Highway.forward: return type `<class 'torch.Tensor'>` is not a `<class 'NoneType'>`.

FWIW this happens on Google Colab, I haven't tried on local.

@saleems11
Copy link

@paleboot, I had the same error

@paleboot
Copy link

paleboot commented May 11, 2021

So this is how I managed to get it to work on Colab. Keep in mind that this is just a naive attempt to debug using informations from the traceback that I got. I am by no means experienced in pytorch, so I don't really know any implications that this will cause. YMMV

  1. Clone the repo as per usual
  2. Open ELMoForManyLangs/elmoformanylangs/modules/highway.py
  3. Edit line 47-48:
47     def forward(self, inputs: torch.Tensor) -> torch.Tensor:  # pylint: disable=arguments-differ
48         current_input = inputs

to

47    def forward(self, *input: torch.Tensor) -> None:  # pylint: disable=arguments-differ
48        current_input = input[0]
  1. Install via pip: pip install -e ELMoForManyLangs/

@saleems11
Copy link

I had changed the python version and suddenly it works.

@paleboot
Copy link

I had changed the python version and suddenly it works.

Which version did you change to? Is it 3.5?

@saleems11
Copy link

No, I had to change it to 3.7 and downloaded torch 1.8.1+cu11.1 on their website, hope this could help.

@paleboot
Copy link

Turns out the culprit is simpler than I thought; the addition of signature check in overrides v5.0.0. The fix is simply by adding check_signature=False in line 46 of ELMoForManyLangs/elmoformanylangs/modules/highway.py:

46    @overrides(check_signature=False)

I've opened PR #96 as a permanent fix, hopefully it gets merged.

@hosjiu1702
Copy link

Turns out the culprit is simpler than I thought; the addition of signature check in overrides v5.0.0. The fix is simply by adding check_signature=False in line 46 of ELMoForManyLangs/elmoformanylangs/modules/highway.py:

46    @overrides(check_signature=False)

I've opened PR #96 as a permanent fix, hopefully it gets merged.

It seems work as a charm.

@uhuohuy
Copy link

uhuohuy commented Mar 22, 2022

Turns out the culprit is simpler than I thought; the addition of signature check in overrides v5.0.0. The fix is simply by adding check_signature=False in line 46 of ELMoForManyLangs/elmoformanylangs/modules/highway.py:

46    @overrides(check_signature=False)

I've opened PR #96 as a permanent fix, hopefully it gets merged.

Thanks a lot. It works for me.

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

5 participants