我是深度学习和python的新手,我正尝试在https://github.com/Nagakiran1/Extending-Google-BERT-as-Question-and-Answering-model-and-Chatbot上重新创建该项目
正如我看到的那样,在项目中有一个名为的文件Bert_QuestionAnswer.ipynb
,这data.txt
是我与原始Bert存储库唯一的区别,我只是将其加载到Google驱动器中,然后将其作为笔记本打开以查看其使用情况。当我运行第一部分的面团时,我会ModuleNotFoundError: No module named 'modeling'
犯错误。它属于哪个库?对于somoebody,这就是问题所在:
看起来它正在尝试从github repo源而不是pip包中导入。
如果您在包含BERT github存储库的目录中运行此文件,请尝试在其他位置运行它。
一如既往的感谢您的帮助。这是引发错误的文件代码:
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from IPython.core.debugger import set_trace
import collections
import json
import math
import os
import random
import modeling
import optimization
import tokenization
import six
import os
import tensorflow as tf
import logging
logging.getLogger('tensorflow').disabled = True
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
import warnings
warnings.filterwarnings("ignore")
import time
from pandas import Series
from nltk.tokenize import sent_tokenize
import gensim.downloader as api
from gensim.parsing.preprocessing import remove_stopwords
word_vectors = api.load("glove-wiki-gigaword-100") # load pre-trained word-vectors from gensim-data
您需要告诉python这个模块在哪里:
import sys
sys.path.append("/path/to/your/bert/repo")
因为python将在他的系统文件夹和当前工作目录中搜索。如果您没有在存储库中运行它,则python找不到此模块。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句