tensorflow VocabularyProcessor

Posted callyblog

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了tensorflow VocabularyProcessor相关的知识,希望对你有一定的参考价值。

from tensorflow.contrib import learn
import numpy as np
vocab_process = learn.preprocessing.VocabularyProcessor(max_document_length=8) # 定义sentence固定长度

vocab_process.fit(w2v_vocab)

vocab_process.transform(
np.reshape( .join(text1_words), [-1])) # text1_words 是已经分词的list

  VocabularyProcessor:类似于keras里面的那个padding,将词映射到词向量词字典的id上

以上是关于tensorflow VocabularyProcessor的主要内容,如果未能解决你的问题,请参考以下文章