Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
GenVQA
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Vision
GenVQA
Commits
ade442ce
Commit
ade442ce
authored
8 years ago
by
tgupta6
Browse files
Options
Downloads
Patches
Plain Diff
answer inference first transforms then bn then add different feat
parent
610ac1fc
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
answer_classifier_cached_features/inference.py
+47
-10
47 additions, 10 deletions
answer_classifier_cached_features/inference.py
with
47 additions
and
10 deletions
answer_classifier_cached_features/inference.py
+
47
−
10
View file @
ade442ce
...
@@ -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_fea
t
)
self
.
obj_atr_
det_packed
=
tf
.
pack
(
obj_atr_
det_lis
t
)
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(
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment