首页 > 解决方案 > 使用 Tensorflow 的问题:检查模块中的 ERROR:root:Internal Python error。以下是此内部错误的回溯

问题描述

导入/使用 tensorflow 或相关包时出现奇怪的错误。我刚刚安装了 tensorflow 版本 2.0.0 并且正在使用 Jupyter Notebook(尽管也尝试在 spyder 上运行但出现相同的错误)。我发现这里解决了这类问题(https://github.com/tensorflow/models/issues/8047),但唯一建议的解决方案对我不起作用(卸载和安装 tensorflow 并下载 Microsoft Visual C++ 或 Visual Studio)。

举个例子,这里是我使用 BERT 时的代码(当我理解正确时,它基于 tensorflow):

import transformers
txt = "bank river"
## bert tokenizer
tokenizer = transformers.BertTokenizer.from_pretrained('bert-base-uncased',     do_lower_case=True)
## bert model
nlp = transformers.TFBertModel.from_pretrained('bert-base-uncased')
## return hidden layer with embeddings
input_ids = np.array(tokenizer.encode(txt))[None,:]  
embedding = nlp(input_ids)
embedding[0][0]

我得到的错误(无论我使用哪个基于tensorflow的包,这个错误都是一样的):

错误:根:检查模块中的内部 Python 错误。以下是此内部错误的回溯。

错误:根:检查模块中的内部 Python 错误。以下是此内部错误的回溯。

错误:根:检查模块中的内部 Python 错误。以下是此内部错误的回溯。

同样,一旦我导入了变压器(或任何其他与 tensorflow 相关的包),我在 jupyter 中所有不相关的其他单元格上都会收到以下错误:

错误!会话/行号在数据库中不是唯一的。历史记录移至新会话 309

标签: tensorflowkerasversionbert-language-model

解决方案


推荐阅读