tensorflow - 使用 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
解决方案
推荐阅读
- autocomplete - 浏览器自动完成建议隐藏 Bootstrap typeahaed 建议
- websocket - 如何将动态端口传递给 NestJS 中的 Websockets-gateway?
- swiftui - 使用 FolioReader 在 SwiftUI 中显示 epub 文件
- c# - 如何检测按钮是否没有被点击/如果没有点击如何让某些东西消失
- html - 如何在 Bootstrap 上的 Switches 中自定义颜色
- php - Laravel 护照在部署后注销用户
- javascript - TypeScript 包装器函数推断类型
- node.js - nodejs中最接近枚举的实现是什么?
- css - 如何水平而不是垂直显示 D3 颜色图例
- java - 如何在@GenericGenerator 中显式传递模式名称?