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

answer inference first transforms then bn then add different feat

parent 610ac1fc
No related branches found
No related tags found
No related merge requests found
...@@ -59,6 +59,8 @@ class AnswerInference(): ...@@ -59,6 +59,8 @@ class AnswerInference():
# self.per_region_answer_scores = [None]*self.batch_size # self.per_region_answer_scores = [None]*self.batch_size
obj_atr_qa_feat = [None]*self.batch_size obj_atr_qa_feat = [None]*self.batch_size
q_a_feat_list = [None]*self.batch_size
obj_atr_det_list = [None]*self.batch_size
for j in xrange(self.batch_size): for j in xrange(self.batch_size):
if j==0: if j==0:
reuse_vars = False reuse_vars = False
...@@ -112,24 +114,45 @@ class AnswerInference(): ...@@ -112,24 +114,45 @@ class AnswerInference():
yes_no_feat_, yes_no_feat_,
[self.num_regions, 1, 1]) [self.num_regions, 1, 1])
obj_atr_qa_feat[j] = tf.concat(
obj_atr_det_list[j] = tf.concat(
2,
[self.selected_noun_adjective[j], obj_det_feat, atr_det_feat])
q_a_feat_list[j] = tf.concat(
2, 2,
[self.selected_noun_adjective[j], yes_no_feat_, obj_det_feat, atr_det_feat, q_feat, a_feat]) [yes_no_feat_, q_feat, a_feat])
# obj_atr_qa_feat[j] = tf.expand_dims( # obj_atr_qa_feat[j] = tf.expand_dims(
# obj_atr_qa_feat[j], # obj_atr_qa_feat[j],
# 0) # 0)
obj_atr_qa_feat = tf.pack(obj_atr_qa_feat) self.obj_atr_det_packed = tf.pack(obj_atr_det_list)
print obj_atr_qa_feat.get_shape() self.q_a_feat_packed = tf.pack(q_a_feat_list)
self.per_region_answer_scores = layers.conv2d( self.obj_atr_det_conv_bn = self.conv_bn(
obj_atr_qa_feat, self.obj_atr_det_packed,
1,
2500, 2500,
'per_region_ans_score_conv_1', 'obj_atr_det_conv_bn')
func = None)
self.q_a_feat_conv_bn = self.conv_bn(
self.q_a_feat_packed,
2500,
'q_a_feat_conv_bn')
self.obj_atr_qa_feat = tf.nn.relu(
self.obj_atr_det_conv_bn + self.q_a_feat_conv_bn)
#obj_atr_qa_feat = tf.pack(obj_atr_qa_feat)
#print obj_atr_qa_feat.get_shape()
# self.per_region_answer_scores = layers.conv2d(
# obj_atr_qa_feat,
# 1,
# 2500,
# 'per_region_ans_score_conv_1',
# func = None)
self.per_region_answer_scores = tf.nn.relu( self.per_region_answer_scores = tf.nn.relu(
layers.batch_norm( layers.batch_norm(
...@@ -197,7 +220,21 @@ class AnswerInference(): ...@@ -197,7 +220,21 @@ class AnswerInference():
feats = tf.transpose(tf.pack(feats), [1,0,2]) feats = tf.transpose(tf.pack(feats), [1,0,2])
return feats return feats
def conv_bn(feat,out_dim,name):
conv_feat = layers.conv2d(
feat,
1,
out_dim,
name,
func = None)
bn_conv_feat = layers.batch_norm(
conv_feat,
tf.constant(self.is_training))
return bn_conv_feat
# def elementwise_product(self, obj_feat, atr_feat, ques_feat, ans_feat): # def elementwise_product(self, obj_feat, atr_feat, ques_feat, ans_feat):
# tiled_ques = tf.tile(tf.reshape(ques_feat,[1, -1]),[self.num_answers,1]) # tiled_ques = tf.tile(tf.reshape(ques_feat,[1, -1]),[self.num_answers,1])
# qa_feat = tf.concat( # qa_feat = tf.concat(
......
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