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上