码迷,mamicode.com
首页 > 其他好文 > 详细

tensorflow VocabularyProcessor

时间:2018-12-23 12:49:37      阅读:131      评论:0      收藏:0      [点我收藏+]

标签:ext1   ssi   固定   process   定义   shape   res   keras   字典   

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

标签:ext1   ssi   固定   process   定义   shape   res   keras   字典   

原文地址:https://www.cnblogs.com/callyblog/p/10163757.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!