pystruct.inference.inference_dispatch

pystruct.inference.inference_dispatch(unary_potentials, pairwise_potentials, edges, inference_method, relaxed=False, return_energy=False, **kwargs)

Wrapper function to dispatch between inference method by string.

Parameters :

unary_potentials : nd-array

Unary potentials of energy function.

pairwise_potentials : nd-array

Pairwise potentials of energy function.

edges : nd-array

Edges of energy function.

inference_method : string

Possible choices currently are:
  • ‘qpbo’ for QPBO alpha-expansion (fast but approximate).
  • ‘dai’ for libDAI wrappers (default to junction tree).
  • ‘lp’ for build-in lp relaxation via GLPK (slow).
  • ‘ad3’ for AD^3 subgradient based dual solution of LP.
  • ‘ad3bb’ for AD^3 base branch-and-bound.
  • ‘ogm’ for OpenGM wrappers.

relaxed : bool (default=False)

Whether to return a relaxed solution (when appropriate) or round to the nearest integer solution. Only used for ‘lp’ and ‘ad3’ inference methods.

return_energy : bool (default=False)

Additionally return the energy of the returned solution (according to the solver). If relaxed=False, this is the energy of the relaxed, not the rounded solution.

Returns :

labels : nd-array

Approximate (usually) MAP variable assignment. If relaxed=True, this is a tuple of unary and pairwise “marginals” from the LP relaxation.