Word2vec 模型载入(tensorflow)

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

   

Word2vec 模型载入(tensorflow)_第1张图片

   

你可能感兴趣的:(Word2vec 模型载入(tensorflow))