列表没有属性值

时间:2020-07-20 10:33:36

标签: python-3.x tensorflow keras nlp

我正在为训练部分之后的句子预测编写代码。到目前为止,我的代码是这样的

import numpy as np
model = Sequential()
l = ['Hello this is police department', 'hello this is 911 emergency']
texts = l.values()
tokenizer = Tokenizer()
tokenizer.fit_on_texts(texts)
X = tokenizer.texts_to_sequences(texts)
model.predict(X)

但是当我运行它时,它给出了一个错误

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-19-9a0876037e02> in <module>()
      2 model = Sequential()
      3 l = ['Hello this is police department', 'hello this is 911 emergency']
----> 4 texts = l.values()
      5 tokenizer = Tokenizer()
      6 tokenizer.fit_on_texts(texts)

AttributeError: 'list' object has no attribute 'values'

为什么会出现此错误?另外,当我传递诸如l[1]之类的索引时,也会出现错误:AttributeError: 'str' object has no attribute 'values'

0 个答案:

没有答案