Skip to content
Snippets Groups Projects
Commit 95bf6bfb authored by tgupta6's avatar tgupta6
Browse files

extract word vectors

parent 15aa9fc0
No related branches found
No related tags found
No related merge requests found
from word2vec.word_vector_management import word_vector_manager
import constants
import ujson
import numpy as np
import os
import tensorflow as tf
model = '/home/tanmay/Code/GenVQA/Exp_Results/models_cvpr/' + \
'ans_through_obj_atr_rel_bin_feats/answer_classifiers/' + \
'model-68000'
sess = tf.InteractiveSession()
word_vec_mgr = word_vector_manager()
model_restorer = tf.train.Saver()
model_restorer.restore(sess, model)
word2vec = word_vec_mgr.pretrained_word_vectors.eval()
classifier_vecs = word_vec_mgr.word_vectors.eval()
outdir = '/home/tanmay/Code/GenVQA/Exp_Results/models_cvpr/word_vectors'
constants.mkdir_if_not_exists(outdir)
# word2vec_file = os.path.join(outdir, 'word2vec.txt')
# np.savetxt(
# word2vec_file,
# word2vec,
# delimiter=',')
# classifier_vecs_file = os.path.join(outdir, 'classifier_vecs.txt')
# np.savetxt(
# classifier_vecs_file,
# classifier_vecs,
# delimiter=',')
with open(constants.vocab_json) as file:
vocab = ujson.load(file)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment