您的位置:首页 > 其它

Word2vec 模型载入(tensorflow)

2015-12-16 20:17 489 查看
opts = Options()

with tf.Graph().as_default(), tf.Session() as session:

model = Word2Vec(opts, session)

if FLAGS.interactive:

#print('load model from file %s %s', opts.save_path, os.path.join(opts.save_path, "/model.ckpt"))

#model.saver.restore(session, os.path.join(opts.save_path, "/model.ckpt"))

model.saver.restore(session, "./data/result/model.ckpt")

#print(model.nearby(['elephant']))

print('finsh model loading')

while True:

print('input your word')

word = sys.stdin.readline().strip()

print('haha')

print(model.nearby(['proton', 'elephant', 'maxwell']))

print(model.nearby([word]))

 
 

[root@cq01-forum-rstree01 embedding]# pwd

/home/users/chenghuige/other/tensorflow/bazel-bin/tensorflow/models/embedding

[root@cq01-forum-rstree01 embedding]# ./word2vec_optimized --train_data ./data/text8 --eval_data ./data/questions-words.txt --save_path ./data/result/ --interactive=1

 
 



 
 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: