首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >AttributeError:'NoneType‘对象没有属性’记号‘

AttributeError:'NoneType‘对象没有属性’记号‘
EN

Stack Overflow用户
提问于 2021-06-01 08:35:34
回答 2查看 3K关注 0票数 1

我正试图通过变压器使用XLNET。但是,我一直遇到"AttributeError:'NoneType‘对象没有属性'tokenize'“的问题。我不知道该怎么做。如果有人能为我指明正确的方向,我们将不胜感激。

代码语言:javascript
运行
复制
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'
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2021-06-01 11:20:55

我假定:

代码语言:javascript
运行
复制
from transformers import XLNetTokenizerFast
tokenizer = XLNetTokenizerFast.from_pretrained('xlnet-base-cased', do_lower_case=True)

有用吗?在本例中,您只是缺少了句式包:

代码语言:javascript
运行
复制
pip install sentencepiece
票数 1
EN

Stack Overflow用户

发布于 2021-10-22 14:16:30

如果安装了SenencePience,并且仍然存在错误

当然,@cronoik的答案是正确的。毫无疑问。但是如果您已经安装了SenencePience软件包,并且仍然存在错误,那么只需使用SenencePience

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67785438

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档