类型错误:“无类型”对象不可调用(XLNet Classifer)

发布于 2025-01-18 18:40:10 字数 411 浏览 1 评论 0 原文

我正在尝试使用Tokenizer,Keras和TensorFlow训练我的模型。 我在哪里遇到错误的代码。

from transformers import TFXLNetModel, XLNetTokenizer
xlnet_model = 'xlnet-large-cased'
xlnet_tokenizer = XLNetTokenizer.from_pretrained(xlnet_model) 

错误:

I am trying to train my model using Tokenizer,Keras and TensorFlow.
Code where I'm getting the error.

from transformers import TFXLNetModel, XLNetTokenizer
xlnet_model = 'xlnet-large-cased'
xlnet_tokenizer = XLNetTokenizer.from_pretrained(xlnet_model) 

Error:

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

溇涏 2025-01-25 18:40:11

如果运行代码,您将首先获得此错误:

ImportError: 
XLNetTokenizer requires the SentencePiece library but it was not found in your environment. Checkout the instructions on the
installation page of its repo: https://github.com/google/sentencepiece#installation and follow the ones
that match your environment

运行!PIP安装句子并重新启动单元格 typeerror 发生。

要解决此问题,您需要重新启动运行时。单击“运行时 - >重新启动运行时”,然后再次运行单元格。

我在 transformers repo中找到了此解决方案,

If you run the code you will first get this error:

ImportError: 
XLNetTokenizer requires the SentencePiece library but it was not found in your environment. Checkout the instructions on the
installation page of its repo: https://github.com/google/sentencepiece#installation and follow the ones
that match your environment

After running !pip install sentencepiece and restarting the cell the TypeError happens.

To fix this you need to restart your runtime. Click "Runtime -> Restart Runtime", then run your cells again.

I found this solution on the transformers repo in this issue report.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文