Commit 6b737666 authored by lucasb-eyer's avatar lucasb-eyer
Browse files

Add clarification (comment) to `compute_unary`.

parent 7c46feec
...@@ -26,8 +26,10 @@ def compute_unary(labels, M, GT_PROB=0.5): ...@@ -26,8 +26,10 @@ def compute_unary(labels, M, GT_PROB=0.5):
n_energy = -np.log((1.0 - GT_PROB) / (M - 1)) n_energy = -np.log((1.0 - GT_PROB) / (M - 1))
p_energy = -np.log(GT_PROB) p_energy = -np.log(GT_PROB)
U = np.zeros((M, len(labels)), dtype='float32') # Note that the order of the following operations is important.
U[:, labels > 0] = n_energy # 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 - 1, np.arange(U.shape[1])] = p_energy
U[:, labels == 0] = u_energy U[:, labels == 0] = u_energy
return U return U
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment