Open spearmint4 opened 1 year ago
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'?
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.
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:
conda install pytorch==1.7.1 cpuonly -c pytorch
.pip install flair==0.6
.pip install --no-deps name2nat
.
For someone who might encounter ModuleNotFoundError: No module named 'torch.utils._pytree'
, install transformers with 4.28.0.
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'