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
582c88c7
Commit
582c88c7
authored
8 years ago
by
tgupta6
Browse files
Options
Downloads
Patches
Plain Diff
change mil loss to use scores instead of softmax prob
parent
cf15ccfa
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
losses.py
+11
-1
11 additions, 1 deletion
losses.py
with
11 additions
and
1 deletion
losses.py
+
11
−
1
View file @
582c88c7
...
...
@@ -84,7 +84,7 @@ def multilabel_margin_loss_inner(y_,y_pred_,margin):
return
tf
.
reduce_mean
(
margin_violation
)
def
mil_loss
(
scores
,
y
,
type
=
'
obj
'
,
epsilon
=
1e-5
):
def
mil_loss
_prob
(
scores
,
y
,
type
=
'
obj
'
,
epsilon
=
1e-5
):
if
type
==
'
obj
'
:
log_prob
=
tf
.
nn
.
log_softmax
(
scores
)
elif
type
==
'
atr
'
:
...
...
@@ -94,6 +94,16 @@ def mil_loss(scores, y, type='obj', epsilon=1e-5):
loss
=
-
tf
.
reduce_sum
(
max_region_scores
)
/
tf
.
maximum
(
tf
.
reduce_sum
(
y
),
epsilon
)
return
loss
def
mil_loss
(
scores
,
y
,
type
=
'
obj
'
,
epsilon
=
1e-5
):
if
type
==
'
obj
'
:
log_prob
=
scores
elif
type
==
'
atr
'
:
log_prob
=
tf
.
log
(
tf
.
maximum
(
epsilon
,
tf
.
nn
.
sigmoid
(
scores
)))
max_region_scores
=
tf
.
minimum
(
tf
.
reduce_max
(
log_prob
*
y
,
0
)
-
1.0
,
0.0
)
loss
=
-
tf
.
reduce_mean
(
max_region_scores
)
#/tf.maximum(tf.reduce_sum(y),epsilon)
return
loss
if
__name__
==
'
__main__
'
:
scores
=
tf
.
constant
([[
0.2
,
0.3
,
0.7
],[
0.8
,
0.2
,
0.9
]])
...
...
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