INNER CODE UNIT · Python
labels
lucasb-eyer/pydensecrf · pydensecrf/utils.py:44
U[:, labels == 0] = -np.log(1.0 / n_labels)
return U
def compute_unary(labels, M, GT_PROB=0.5):
"""Deprecated, use `unary_from_labels` instead."""
warning("pydensecrf.compute_unary is deprecated, use unary_from_labels instead.")
return unary_from_labels(labels, M, GT_PROB)
def unary_from_softmax(sm, scale=None, clip=1e-5):
"""Converts softmax class-probabilities to unary potentials (NLL per node).
Parameters
----------
sm: numpy.array
Output of a softmax where the first dimension is the classes,