程序问答   发布时间:2022-06-02  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了AttributeError: 'NoneType' 对象没有属性 'tokenize'大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

如何解决AttributeError: 'NoneType' 对象没有属性 'tokenize'?

开发过程中遇到AttributeError: 'NoneType' 对象没有属性 'tokenize'的问题如何解决?下面主要结合日常开发的经验,给出你关于AttributeError: 'NoneType' 对象没有属性 'tokenize'的解决方法建议,希望对你解决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'

解决方法

@H_489_10@

我假设:

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,请注明来意。