【发布时间】:2020-09-08 16:16:16
【问题描述】:
假设我有一个单词/句子序列:“我喜欢食物”
如果我使用 keras one_hot 进行编码:
from keras.preprocessing.text import one_hot
one_hot('I like food',50)
它给了我以下值:[10, 39, 17]
但是,假设我有这样的输入序列:['Add more', 'Add less', 'Do little more'] 这里的每个条目就像一个句子中的一个词。因此,我想将“Add more”、“Add less”和“Do little more”编码为一个单词。所有条目由完整的序列或句子组成。
我怎样才能像 keras 中的 one_hot 一样对其进行编码。使用 one_hot 显示错误:
'list' 对象没有属性'lower'
【问题讨论】:
标签: tensorflow keras nlp word-embedding python-textprocessing