简体   繁体   English

NameError: name 'BertModel' 未定义,导入 Bert 提取摘要器时出错

[英]NameError: name 'BertModel' is not defined, error while importing Bert extractive summarizer

I have freshly installed Anaconda module and installed Bert extractive summarizer package.我刚刚安装了 Anaconda 模块并安装了 Bert 提取摘要程序包。 The following error is being encountered by me while importing the module:我在导入模块时遇到以下错误:

from transformers import *
from summarizer import Summarizer

~\anaconda3\lib\site-packages\summarizer\model_processors.py in <module>
----> 1 from summarizer.bert_parent import BertParent
      2 from summarizer.cluster_features import ClusterFeatures
      3 from summarizer.sentence_handler import SentenceHandler
      4 from typing import List
      5 from abc import abstractmethod

~\anaconda3\lib\site-packages\summarizer\bert_parent.py in <module>
      9 
     10 
---> 11 class BertParent(object):
     12 
     13     """

~\anaconda3\lib\site-packages\summarizer\bert_parent.py in BertParent()
     16 
     17     MODELS = {
---> 18         'bert-base-uncased': (BertModel, BertTokenizer),
     19         'bert-large-uncased': (BertModel, BertTokenizer),
     20         'xlnet-base-cased': (XLNetModel, XLNetTokenizer),

NameError: name 'BertModel' is not defined

Please help me in resolving this issue.请帮我解决这个问题。 Thanks in advance.提前致谢。

Which version of python are you using.您使用的是哪个版本的python。 I face a similar error which i used python 3.5.x.我遇到了类似的错误,我使用了 python 3.5.x。 This error got resolved once i uninstalled python3.5 and installed python 3.6一旦我卸载了 python3.5 并安装了 python 3.6,这个错误就得到了解决

conda install python=3.6

Run this command and then restart your notebook.运行此命令,然后重新启动您的笔记本。 It will work它会工作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 bert-extractive-summarizer 导入警告/错误 - bert-extractive-summarizer import warning/error 导入张量流时出错:NameError: name &#39;python&#39; 未定义 - Error importing tensorflow: NameError: name 'python' is not defined 导入后Python getopt模块错误“NameError:名称&#39;opts&#39;未定义” - Python getopt module error "NameError: name 'opts' is not defined" after importing 'BertModel' object 没有属性 'bert' error german bert model - 'BertModel' object has no attribute 'bert' error german bert model NameError:名称未定义。 循环进口 - NameError: name is not defined. Circular Importing 熊猫不进口吗? 'NameError:全局名称'pandas'未定义' - Is Pandas not importing? 'NameError: global name 'pandas' is not defined' NameError:导入 spyrmsd 后未定义名称“加载” - NameError: name 'load' is not defined after importing spyrmsd 使用Selenium的while函数循环会引发错误NameError:未定义名称&#39;neadaclick&#39; - Looping with while function with Selenium throws error NameError: name 'neadaclick' is not defined 执行程序时出现错误“ NameError:名称&#39;TLSExtSupportedGroup&#39;未定义” - Getting Error “NameError: name 'TLSExtSupportedGroup' is not defined” while executing the program ImportError:无法从“变压器”导入名称“AlbertModel”-Bert summaryer - ImportError: cannot import name 'AlbertModel' from 'transformers' - Bert summarizer
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM