无法导入bert.tokenization

时间:2019-06-12 05:14:55

标签: python-3.x deep-learning nlp

我正在使用Google Colab,并且以下导入无法正常进行:

git checkout master 

我收到此错误:

from bert.tokenization import FullTokenizer

我试图通过运行以下命令来安装bert:

ModuleNotFoundError: No module named 'bert.tokenization'

您知道如何解决此错误吗?

5 个答案:

答案 0 :(得分:3)

我找到了:

!pip install bert-tensorflow

答案 1 :(得分:2)

安装: pip install bert-for-tf2

然后导入

from bert import bert_tokenization BertTokenizer = bert_tokenization.FullTokenizer

答案 2 :(得分:1)

对于使用TensorFlow 2.0和bert-for-tf2库遇到此问题的任何人,我发现使用pip3安装后我会丢失一些文件。我已经在这里发布了我的解决方案:

https://github.com/google-research/bert/issues/638#issuecomment-592488730

答案 3 :(得分:0)

或者您可以使用早期版本的BERT以避免进一步的复杂性(目前为Atleast)

!pip install tensorflow-gpu==1.15.0
!pip install bert-tensorflow
from sklearn.model_selection import train_test_split
import pandas as pd
import tensorflow as tf
import tensorflow_hub as hub
from datetime import datetime
import bert
from bert import run_classifier
from bert import optimization
from bert import tokenization

答案 4 :(得分:-1)

这对我有用:

Host

要使用:

!pip install bert-tokenizer

不是import bert_tokenizer as tokenizer !!!

相关问题