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

Error from 'my_nanat = Name2nat()' #5

Open
spearmint4 opened this issue Aug 7, 2023 · 4 comments
Open

Error from 'my_nanat = Name2nat()' #5

spearmint4 opened this issue Aug 7, 2023 · 4 comments

Comments

@spearmint4
Copy link

I receive the following error when after running 'my_nanat = Name2nat()'

Python 3.9.2 (tags/v3.9.2:1a79785, Feb 19 2021, 13:44:55) [MSC v.1928 64 bit (AMD64)] on win32
from name2nat import Name2nat
my_nanat = Name2nat()
Traceback (most recent call last):
File "C:\Program Files\JetBrains\PyCharm Community Edition 2022.3.2\plugins\python-ce\helpers\pydev\pydevconsole.py", line 364, in runcode
coro = func()
File "", line 2, in
File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\site-packages\name2nat\name2nat.py", line 11, in init
self.classifier = TextClassifier.load(ckpt)
File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\site-packages\flair\models\text_classification_model.py", line 137, in load
return cast("TextClassifier", super().load(model_path=model_path))
File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\site-packages\flair\nn\model.py", line 944, in load
return cast("DefaultClassifier", super().load(model_path=model_path))
File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\site-packages\flair\nn\model.py", line 559, in load
return cast("Classifier", super().load(model_path=model_path))
File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\site-packages\flair\nn\model.py", line 191, in load
state = load_torch_state(model_file)
File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\site-packages\flair\file_utils.py", line 359, in load_torch_state
return torch.load(f, map_location="cpu")
File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\site-packages\torch\serialization.py", line 815, in load
return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)
File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\site-packages\torch\serialization.py", line 1043, in _legacy_load
result = unpickler.load()
File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\site-packages\torch\nn\modules\rnn.py", line 325, in setstate
for w in self._flat_weights]
File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\site-packages\torch\nn\modules\module.py", line 1614, in getattr
raise AttributeError("'{}' object has no attribute '{}'".format(
AttributeError: 'GRU' object has no attribute '_flat_weights'

@AnaKuzina
Copy link

AnaKuzina commented Oct 21, 2023

Hey @spearmint4,
did you manage to bypass this error?

I get the same one with a little bit different message:
AttributeError: 'GRU' object has no attribute '_flat_weights'. Did you mean: '_all_weights'?

@SinaOzdemir
Copy link

I have the same problem. Quick googling indicates Name2nat has a problem with initiating GRU. Some other package suggests that it might be related to pytorch version. It might also be that one of the dependencies of the Name2nat got updated and made this package useless.

@haojoeyzhang
Copy link

haojoeyzhang commented Dec 17, 2023

I successfully got the package to function.

The problem arises because the package depends on flair but does not specify a specific version of it. Additionally, flair itself does not clearly specify the required PyTorch version. This oversight leads to further complications as the necessary version of PyTorch is not available through pip. As a result, the system defaults to installing the latest versions of these dependencies, potentially leading to compatibility issues.

To resolve this, please follow these steps:

  1. Create a new environment using Conda. Ensure that the Python version is either 3.6 or 3.7.
  2. Install PyTorch version 1.7.1. Use this command: conda install pytorch==1.7.1 cpuonly -c pytorch.
  3. Install a specific version of Flair, version 0.6, with the following command: pip install flair==0.6.
  4. Finally, install the name2nat package, but bypass its dependencies by using: pip install --no-deps name2nat.
    image

@sh0416
Copy link

sh0416 commented Mar 18, 2024

For someone who might encounter ModuleNotFoundError: No module named 'torch.utils._pytree', install transformers with 4.28.0.

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