我最近在实践《手把手教你使用预训练模型ernie_gen进行finetune自己想要的场景》的代码时,在运行module = hub.Module(name="ernie_gen")的时候就会报错,具体错误如下:
---------------------------------------------------------------------------ModuleNotFoundError Traceback (most recent call last) in
1 import paddlehub as hub
2
----> 3 module = hub.Module(name="ernie_gen")
4
5 result = module.finetune(
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddlehub/module/module.py in __new__(cls, name, directory, module_dir, version, **kwargs)
100 if name:
101 module = cls.init_with_name(
--> 102 name=name, version=version, **kwargs)
103 elif directory:
104 module = cls.init_with_directory(directory=directory, **kwargs)
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddlehub/module/module.py in init_with_name(cls, name, version, **kwargs)
176 logger.info(tips)
177 lock.flock(fp_lock, lock.LOCK_UN)
--> 178 return cls.init_with_directory(directory=module_dir[0], **kwargs)
179
180 @classmethod
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddlehub/module/module.py in init_with_directory(cls, directory, **kwargs)
191 dirname = os.path.join(*list(os.path.split(directory)[:-1]))
192 sys.path.insert(0, dirname)
--> 193 _module = importlib.import_module("{}.module".format(basename))
194 for _item, _cls in inspect.getmembers(_module, inspect.isclass):
195 _item = _module.__dict__[_item]
/opt/conda/envs/python35-paddle120-env/lib/python3.7/importlib/__init__.py in import_module(name, package)
125 break
126 level += 1
--> 127 return _bootstrap._gcd_import(name[level:], package, level)
128
129
/opt/conda/envs/python35-paddle120-env/lib/python3.7/importlib/_bootstrap.py in _gcd_import(name, package, level)
/opt/conda/envs/python35-paddle120-env/lib/python3.7/importlib/_bootstrap.py in _find_and_load(name, import_)
/opt/conda/envs/python35-paddle120-env/lib/python3.7/importlib/_bootstrap.py in _find_and_load_unlocked(name, import_)
/opt/conda/envs/python35-paddle120-env/lib/python3.7/importlib/_bootstrap.py in _load_unlocked(spec)
/opt/conda/envs/python35-paddle120-env/lib/python3.7/importlib/_bootstrap_external.py in exec_module(self, module)
/opt/conda/envs/python35-paddle120-env/lib/python3.7/importlib/_bootstrap.py in _call_with_frames_removed(f, *args, **kwds)
~/.paddlehub/modules/ernie_gen/module.py in
20 import numpy as np
21 import paddle
---> 22 import paddle.nn as nn
23 from paddle.io import DataLoader
24 import paddlehub as hub
ModuleNotFoundError: No module named 'paddle.nn'
我选定的paddlepaddle的版本为2.1.2版本,应该不是网上说的paddle版本过低,有哪位大佬可以来帮我解决一下问题吗
# 下载并导入最新版本的paddlehub
!pip install -U paddlehub -i https://pypi.tuna.tsinghua.edu.cn/simple
ernie_gen模型:https://www.paddlepaddle.org.cn/hubdetail?name=ernie_gen&en_category=TextGeneration
嗯嗯,谢谢大佬