Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
pydensecrf
Commits
6b737666
Commit
6b737666
authored
Aug 20, 2016
by
lucasb-eyer
Browse files
Add clarification (comment) to `compute_unary`.
parent
7c46feec
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
2 deletions
+4
-2
pydensecrf/utils.py
pydensecrf/utils.py
+4
-2
No files found.
pydensecrf/utils.py
View file @
6b737666
...
...
@@ -26,8 +26,10 @@ def compute_unary(labels, M, GT_PROB=0.5):
n_energy
=
-
np
.
log
((
1.0
-
GT_PROB
)
/
(
M
-
1
))
p_energy
=
-
np
.
log
(
GT_PROB
)
U
=
np
.
zeros
((
M
,
len
(
labels
)),
dtype
=
'float32'
)
U
[:,
labels
>
0
]
=
n_energy
# Note that the order of the following operations is important.
# That's because the later ones overwrite part of the former ones, and only
# after all of them is `U` correct!
U
=
np
.
full
((
M
,
len
(
labels
)),
n_energy
,
dtype
=
'float32'
)
U
[
labels
-
1
,
np
.
arange
(
U
.
shape
[
1
])]
=
p_energy
U
[:,
labels
==
0
]
=
u_energy
return
U
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment