paddlehub 2.0.0rc0
paddlenlp 2.0.7
paddlepaddle-gpu 2.0.2.post101
在运行官方的:PaddleHub2.0——使用动态图版预训练模型ERNIE实现快递单时候,执行到
model = hub.Module(name='ernie', task='token-cls', label_map=label_map)
报一下错误:[2023-03-23 17:06:29,394] [ WARNING] - The _initialize method in HubModule will soon be deprecated, you can use the __init__() to handle the initialization of the object ---------------------------------------------------------------------------TypeError Traceback (most recent call last)/tmp/ipykernel_1093/3000876241.py in <module> 1 # 选择所需要的模型 ----> 2 model = hub.Module(name='ernie', task='token-cls', label_map=label_map) /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddlehub/module/module.py in __new__(cls, name, directory, version, source, update, branch, **kwargs) 170 if name: 171 module = cls.init_with_name( --> 172 name=name, version=version, source=source, update=update, branch=branch, **kwargs) 173 CacheUpdater("update_cache", module=name, version=version).start() 174 elif directory: /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddlehub/module/module.py in init_with_name(cls, name, version, source, update, branch, **kwargs) 272 ) 273 user_module = user_module_cls(directory=directory) --> 274 user_module._initialize(**kwargs) 275 return user_module 276 /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddlehub/compat/paddle_utils.py in runner(*args, **kwargs) 218 def runner(*args, **kwargs): 219 with static_mode_guard(): --> 220 return func(*args, **kwargs) 221 222 return runner TypeError: _initialize() got an unexpected keyword argument 'task'
并在多次跟换hub版本任然报次错误。如何解决。
2条答案
按热度按时间8fq7wneg1#
在AIstudio环境中,文本分类模型无法运行。错误信息显示'Ernie'对象没有'metric'属性。请检查模型是否正确加载,或者尝试使用其他模型进行文本分类。
deikduxw2#
我解决了这个问题,使用的是预训练模型Ernie的版本。