简体   繁体   English

"如何解决python中的这个属性错误?"

[英]How to solve this attribute error in python?

def encode_sequences(tokenizer, length , lines): seq = tokenizer.text_to_sequences(lines) seq = pad_sequences(seq, maxlen = length, padding = 'posts') return seq from sklearn.model_selection import train_test_split train , test = train_test_split(deu_eng , test_size = 0.2, random_state = 12) trainX = encode_sequences(deu_tokenizer, deu_length, train[:,1]) trainY = encode_sequences(eng_tokenizer, eng_length, train[:,0]) testX = encode_sequences(deu_tokenizer, deu_length, test[:,1]) testY = encode_sequences(eng_tokenizer, eng_length, test[:,0])

I believe you have mispelled the texts_to_sequences attribute.我相信您拼错了 texts_to_sequences 属性。 The error states that it cannot find the text_to_sequences method in the line:该错误表明它在该行中找不到 text_to_sequences 方法:

seq = tokenizer.text_to_sequences(lines)

From the documentation , you can see that this method should be spelled: 从文档中,您可以看到此方法应拼写为:

seq = tokenizer.texts_to_sequences(lines)

This should resolve the error.这应该可以解决错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM