大佬教程收集整理的这篇文章主要介绍了AttributeError: 'NoneType' 对象没有属性 'tokenize',大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试通过转换器使用 XLNET。但是我不断收到问题“AttributeError: 'nonetype' 对象没有属性 'tokenize'”。我不确定如何继续。如果有人能指出我正确的方向,我将不胜感激。
tokenizer = XLNetTokenizer.from_preTrained('xlnet-base-cased',do_lower_case=TruE)
print(' Original: ',X_Train[1])
# Print the tweet split into tokens.
print('Tokenized: ',tokenizer.tokenize(X_Train[1]))
# Print the tweet mapped to token IDs.
print('Token IDs: ',tokenizer.convert_tokens_to_IDs(tokenizer.tokenize(X_Train[1])))
Original: hey angel duh sexy really thanks haha
---------------------------------------------------------------------------
AttributeError TraceBACk (most recent call last)
<ipython-input-67-2b1b432b3e15> in <module>()
2
3 # Print the tweet split into tokens.
----> 4 print('Tokenized: ',tokenizer.tokenize(X_Train[2]))
5
6 # Print the tweet mapped to token IDs.
AttributeError: 'nonetype' object has no attribute 'tokenize'
我假设:
from transformers import XLNetTokenizerFast
tokenizer = XLNetTokenizerFast.from_preTrained('xlnet-base-cased',do_lower_case=TruE)
有效吗? 在这种情况下,您只是缺少 sentencepiece 包:
pip install sentencepiece
以上是大佬教程为你收集整理的AttributeError: 'NoneType' 对象没有属性 'tokenize'全部内容,希望文章能够帮你解决AttributeError: 'NoneType' 对象没有属性 'tokenize'所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。