【发布时间】:2020-02-06 23:07:59
【问题描述】:
在标记器之后,我的字符串列表试图获取单词的值及其编号的关联。 f.e: = 3 我该怎么做?? (Python) 这是代码
sentences_train, sentences_test, y_train, y_test = train_test_split(X,y, test_size=0.2, random_state=42)
from keras.preprocessing.text import Tokenizer
tokenizer = Tokenizer(num_words=5000)
tokenizer.fit_on_texts(sentences_train)
X_train = tokenizer.texts_to_sequences(sentences_train)
X_test = tokenizer.texts_to_sequences(sentences_test)
vocab_size = len(tokenizer.word_index) + 1
【问题讨论】:
-
欢迎来到 StackOverflow。见minimal, reproducible example。在您发布 MRE 代码并准确说明问题之前,我们无法有效地帮助您。我们应该能够将您发布的代码粘贴到文本文件中并重现您指定的问题。