Skip to content

Commit e88e90f

Browse files
committed
Add documentation comment to compute_unary.
1 parent 74652c2 commit e88e90f

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

pydensecrf/utils.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,21 @@ def compute_unary(labels, M, GT_PROB=0.5):
55
"""
66
Simple classifier that is 50% certain that the annotation is correct
77
(same as in the inference example).
8+
9+
10+
Parameters
11+
----------
12+
labels: nummpy.array
13+
The label-map.
14+
M: int
15+
The number of labels there are.
16+
GT_PROB: float
17+
The certainty of the ground-truth (must be within (0,1)).
818
"""
19+
assert 0 < GT_PROB < 1, "`GT_PROB must be in (0,1)."
20+
21+
labels = labels.flatten()
22+
923
u_energy = -np.log(1.0 / M)
1024
n_energy = -np.log((1.0 - GT_PROB) / (M - 1))
1125
p_energy = -np.log(GT_PROB)

0 commit comments

Comments
 (0)