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

add yes no num feat

parent 4ae6983f
No related branches found
No related tags found
No related merge requests found
...@@ -135,7 +135,7 @@ class graph_creator(): ...@@ -135,7 +135,7 @@ class graph_creator():
self.noun_embed, self.noun_embed,
self.adjective_embed, self.adjective_embed,
self.num_neg_answers + 1, self.num_neg_answers + 1,
self.plh['yes_no_feat'], self.plh['yes_no_num_feat'],
self.plh['keep_prob'], self.plh['keep_prob'],
self.training) self.training)
...@@ -270,9 +270,9 @@ class graph_creator(): ...@@ -270,9 +270,9 @@ class graph_creator():
size=self.batch_size) size=self.batch_size)
self.plh.add_placeholder( self.plh.add_placeholder(
'yes_no_feat', 'yes_no_num_feat',
tf.float32, tf.float32,
shape = [self.num_neg_answers+1,2], shape = [self.num_neg_answers+1,6],
size=self.batch_size) size=self.batch_size)
def get_noun_adjective_embeddings(self): def get_noun_adjective_embeddings(self):
...@@ -873,7 +873,7 @@ def create_feed_dict_creator(plh, num_neg_answers): ...@@ -873,7 +873,7 @@ def create_feed_dict_creator(plh, num_neg_answers):
inputs['positive_nouns_vec_enc'] = vqa_batch['positive_nouns_vec_enc'] inputs['positive_nouns_vec_enc'] = vqa_batch['positive_nouns_vec_enc']
inputs['positive_adjectives_vec_enc'] = vqa_batch['positive_adjectives_vec_enc'] inputs['positive_adjectives_vec_enc'] = vqa_batch['positive_adjectives_vec_enc']
inputs['yes_no_feat'] = vqa_batch['yes_no_feat'] inputs['yes_no_num_feat'] = vqa_batch['yes_no_num_feat']
#batch x 18 x 2 #batch x 18 x 2
# Create vgenome inputs # Create vgenome inputs
......
...@@ -136,7 +136,7 @@ class data(): ...@@ -136,7 +136,7 @@ class data():
batch['positive_adjectives'], batch['positive_adjectives'],
positive_answer_unencoded) positive_answer_unencoded)
batch['yes_no_feat'] = self.is_yes_no( batch['yes_no_num_feat'] = self.is_yes_no_num(
positive_answer_unencoded, positive_answer_unencoded,
negative_answers_unencoded) negative_answers_unencoded)
...@@ -169,23 +169,40 @@ class data(): ...@@ -169,23 +169,40 @@ class data():
return batch return batch
def is_yes_no( def is_yes_no_num(
self, self,
positive_answer_unencoded, positive_answer_unencoded,
negative_answers_unencoded): negative_answers_unencoded):
feat = np.zeros([self.num_neg_answers+1,2]) feat = np.zeros([self.num_neg_answers+1,6])
if 'yes' in positive_answer_unencoded: if 'yes' in positive_answer_unencoded:
feat[0,0] = 1.0 feat[0,0] = 1.0
elif 'no' in positive_answer_unencoded: elif 'no' in positive_answer_unencoded:
feat[0,1] = 1.0 feat[0,1] = 1.0
elif '0' in positive_answer_unencoded:
feat[0,2] = 1.0
elif '1' in positive_answer_unencoded:
feat[0,3] = 1.0
elif '2' in positive_answer_unencoded:
feat[0,4] = 1.0
elif '3' in positive_answer_unencoded:
feat[0,5] = 1.0
for i in xrange(1,self.num_neg_answers+1): for i in xrange(1,self.num_neg_answers+1):
if 'yes' in negative_answers_unencoded[i-1]: if 'yes' in negative_answers_unencoded[i-1]:
feat[i,0] = 1.0 feat[i,0] = 1.0
elif 'no' in negative_answers_unencoded[i-1]: elif 'no' in negative_answers_unencoded[i-1]:
feat[i,1] = 1.0 feat[i,1] = 1.0
elif '0' in negative_answers_unencoded:
feat[i,2] = 1.0
elif '1' in negative_answers_unencoded:
feat[i,3] = 1.0
elif '2' in negative_answers_unencoded:
feat[i,4] = 1.0
elif '3' in negative_answers_unencoded:
feat[i,5] = 1.0
return feat return feat
......
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