Module Import alias identifier ImportFrom alias ImportFrom alias ImportFrom alias FunctionDef arguments args NameParam NameParam defaults NameLoad body If CompareIs NameLoad NameLoad body Assign NameStore BinOpAdd Call AttributeLoad NameLoad attr NameLoad Num Assign NameStore Call AttributeLoad Call AttributeLoad NameLoad attr TupleLoad Call AttributeLoad NameLoad attr Call NameLoad NameLoad AttributeLoad NameLoad attr keyword TupleLoad NameLoad NameLoad attr Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Return BoolOpAnd Call AttributeLoad NameLoad attr CompareEq SubscriptLoad NameLoad ExtSlice Slice Index Num Call AttributeLoad NameLoad attr Num BinOpSub NameLoad Num Call AttributeLoad NameLoad attr CompareEq SubscriptLoad NameLoad ExtSlice Slice Index Num Call AttributeLoad NameLoad attr Num NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam NameParam NameParam defaults Num Num Num NameLoad body Expr Str ImportFrom alias Assign TupleStore NameStore NameStore Call NameLoad NameLoad NameLoad NameLoad If Call NameLoad keyword NameLoad keyword Call NameLoad NameLoad body Assign NameStore Call NameLoad Call AttributeLoad Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr attr Call AttributeLoad NameLoad attr NameLoad keyword AttributeLoad NameLoad attr orelse If Call NameLoad keyword NameLoad keyword Call NameLoad NameLoad body Assign NameStore Call NameLoad NameLoad NameLoad NameLoad orelse Assign NameStore Call NameLoad NameLoad NameLoad NameLoad keyword NameLoad keyword NameLoad Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Assign TupleStore NameStore NameStore AttributeLoad NameLoad attr Assign NameStore UnaryOpUSub Call AttributeLoad NameLoad attr NameLoad keyword AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr NameLoad keyword AttributeLoad NameLoad attr Assign NameStore ListComp ListLoad comprehension NameStore Call NameLoad NameLoad Assign NameStore ListComp ListLoad comprehension NameStore Call NameLoad NameLoad For TupleStore NameStore NameStore Call NameLoad NameLoad NameLoad body Expr Call AttributeLoad SubscriptLoad NameLoad Index SubscriptLoad NameLoad Index Num attr SubscriptLoad NameLoad Index Num Expr Call AttributeLoad SubscriptLoad NameLoad Index SubscriptLoad NameLoad Index Num attr NameLoad Expr Call AttributeLoad SubscriptLoad NameLoad Index SubscriptLoad NameLoad Index Num attr SubscriptLoad NameLoad Index Num Expr Call AttributeLoad SubscriptLoad NameLoad Index SubscriptLoad NameLoad Index Num attr AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr TupleLoad NameLoad NameLoad Assign NameStore Call AttributeLoad NameLoad attr TupleLoad NameLoad NameLoad Assign NameStore Call AttributeLoad NameLoad attr TupleLoad NameLoad NameLoad NameLoad Assign NameStore ListLoad Assign NameStore Num While CompareLt NameLoad NameLoad body For NameStore Call NameLoad NameLoad NameLoad body If UnaryOpNot SubscriptLoad NameLoad Index NameLoad body Assign NameStore ListLoad NameLoad Assign NameStore BinOpAdd NameLoad Num Assign SubscriptStore NameLoad Index NameLoad NameLoad Break Assign NameStore NameLoad While NameLoad body Assign NameStore Call AttributeLoad NameLoad attr Num Expr Call AttributeLoad NameLoad attr NameLoad For TupleStore NameStore NameStore Call NameLoad SubscriptLoad NameLoad Index NameLoad SubscriptLoad NameLoad Index NameLoad body If UnaryOpNot SubscriptLoad NameLoad Index NameLoad body Assign SubscriptStore NameLoad Index NameLoad NameLoad Expr Call AttributeLoad NameLoad attr NameLoad Assign SubscriptStore NameLoad Index NameLoad NameLoad Assign SubscriptStore NameLoad Index NameLoad NameLoad orelse If UnaryOpNot CompareEq SubscriptLoad NameLoad Index NameLoad NameLoad body Raise Call NameLoad Str For NameStore SubscriptLoad NameLoad Slice Num body Assign NameStore SubscriptLoad NameLoad Index NameLoad If CompareNotEq NameLoad Num body Assign NameStore Call AttributeLoad NameLoad attr BinOpAdd BinOpAdd SubscriptLoad NameLoad Index NameLoad SubscriptLoad NameLoad Index NameLoad SubscriptLoad NameLoad Index NameLoad keyword Num AugAssignSub NameStore Call AttributeLoad NameLoad attr AugAssignAdd SubscriptStore NameLoad Index NameLoad NameLoad For NameStore NameLoad body Assign NameStore SubscriptLoad NameLoad Index NameLoad If CompareNotEq NameLoad Num body Assign NameStore BinOpAdd BinOpAdd SubscriptLoad NameLoad Index NameLoad SubscriptLoad NameLoad Index NameLoad AttributeLoad SubscriptLoad NameLoad Index NameLoad attr AugAssignAdd NameStore BinOpSub SubscriptLoad NameLoad Index NameLoad Call AttributeLoad NameLoad attr BinOpAdd BinOpAdd SubscriptLoad NameLoad Index NameLoad SubscriptLoad NameLoad Index NameLoad SubscriptLoad NameLoad Index NameLoad keyword Num Assign NameStore Call AttributeLoad NameLoad attr keyword Num AugAssignSub NameStore Call AttributeLoad NameLoad attr AugAssignAdd SubscriptStore NameLoad Index NameLoad NameLoad Return Call AttributeLoad NameLoad attr BinOpAdd BinOpAdd NameLoad NameLoad NameLoad keyword Num decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam NameParam defaults Num Num Num body Assign NameStore Call NameLoad NameLoad Assign TupleStore NameStore NameStore AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr TupleLoad NameLoad Num NameLoad Assign NameStore Call AttributeLoad NameLoad attr TupleLoad NameLoad NameLoad For NameStore Call NameLoad NameLoad body Assign NameStore Num For TupleStore NameStore TupleStore NameStore NameStore Call NameLoad Call NameLoad NameLoad NameLoad body Assign NameStore BinOpSub BinOpAdd BinOpAdd SubscriptLoad NameLoad Index SubscriptLoad NameLoad Index Num AttributeLoad NameLoad attr SubscriptLoad NameLoad Index SubscriptLoad NameLoad Index Num SubscriptLoad NameLoad Index TupleLoad NameLoad Num Assign NameStore Call AttributeLoad SubscriptLoad NameLoad Index TupleLoad NameLoad Num attr Assign NameStore Call AttributeLoad NameLoad attr NameLoad keyword Num AugAssignSub NameStore Call AttributeLoad NameLoad attr NameLoad Assign NameStore BinOpAdd BinOpMult NameLoad NameLoad BinOpMult BinOpSub Num NameLoad NameLoad Assign SubscriptStore NameLoad Index TupleLoad NameLoad Num NameLoad Assign NameStore BinOpSub NameLoad NameLoad AugAssignAdd SubscriptStore NameLoad Index SubscriptLoad NameLoad Index Num NameLoad AugAssignAdd NameStore Call AttributeLoad Call AttributeLoad NameLoad attr NameLoad attr Assign NameStore BinOpSub BinOpAdd BinOpAdd SubscriptLoad NameLoad Index SubscriptLoad NameLoad Index Num NameLoad SubscriptLoad NameLoad Index SubscriptLoad NameLoad Index Num SubscriptLoad NameLoad Index TupleLoad NameLoad Num Assign NameStore Call AttributeLoad SubscriptLoad NameLoad Index TupleLoad NameLoad Num attr Assign NameStore Call AttributeLoad NameLoad attr NameLoad keyword Num AugAssignSub NameStore Call AttributeLoad NameLoad attr SubscriptLoad NameLoad Index TupleLoad NameLoad Num Assign NameStore BinOpAdd BinOpMult NameLoad NameLoad BinOpMult BinOpSub Num NameLoad NameLoad Assign SubscriptStore NameLoad Index TupleLoad NameLoad Num NameLoad Assign NameStore BinOpSub NameLoad NameLoad AugAssignAdd SubscriptStore NameLoad Index SubscriptLoad NameLoad Index Num NameLoad AugAssignAdd NameStore Call AttributeLoad Call AttributeLoad NameLoad attr NameLoad attr If CompareLt NameLoad NameLoad body Break Return Call AttributeLoad NameLoad attr BinOpAdd NameLoad NameLoad keyword Num decorator_list
N/A N/A numpy np scipy sparse common _validate_params utils.graph_functions is_forest edges_to_graph N/A N/A edges n_vertices N/A None N/A N/A N/A n_vertices None N/A N/A n_vertices N/A N/A N/A np max edges 1 N/A graph N/A N/A N/A N/A sparse coo_matrix N/A N/A N/A np ones N/A len edges N/A edges T shape N/A n_vertices n_vertices tocsr N/A graph N/A is_chain N/A N/A edges n_vertices N/A N/A N/A Check if edges specify a chain and are in order. N/A N/A N/A N/A np all N/A N/A edges N/A N/A N/A 0 N/A N/A np arange 0 N/A n_vertices 1 N/A N/A np all N/A N/A edges N/A N/A N/A 1 N/A N/A np arange 1 n_vertices N/A inference_max_product N/A N/A unary_potentials pairwise_potentials edges max_iter damping tol relaxed N/A 30 0.5 1e-05 None N/A N/A Max-product inference.

    In case the edges specify a tree, dynamic programming is used
    producing a result in only a single pass.

    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.

    max_iter : int (default=10)
        Maximum number of iterations. Ignored if graph is a tree.

    damping : float (default=.5)
        Daming of messages in loopy message passing.
        Ignored if graph is a tree.

    tol : float (default=1e-5)
        Stopping tollerance for loopy message passing.
     _viterbi viterbi N/A N/A n_states pairwise_potentials N/A _validate_params unary_potentials pairwise_potentials edges N/A N/A is_chain edges edges n_vertices N/A len unary_potentials N/A N/A y N/A viterbi N/A N/A N/A N/A unary_potentials astype N/A np float copy N/A N/A np array pairwise_potentials dtype N/A np float N/A N/A N/A is_forest edges edges n_vertices N/A len unary_potentials N/A N/A y N/A tree_max_product unary_potentials pairwise_potentials edges N/A N/A y N/A iterative_max_product unary_potentials pairwise_potentials edges max_iter max_iter damping damping N/A y N/A tree_max_product N/A N/A unary_potentials pairwise_potentials edges N/A N/A N/A N/A n_vertices n_states N/A unary_potentials shape N/A parents N/A N/A N/A np ones n_vertices dtype N/A np int N/A visited N/A N/A np zeros n_vertices dtype N/A np bool N/A neighbors N/A N/A N/A i N/A range n_vertices N/A pairwise_weights N/A N/A N/A i N/A range n_vertices N/A N/A pw edge N/A zip pairwise_potentials edges N/A N/A N/A N/A N/A neighbors N/A N/A edge N/A 0 append N/A edge N/A 1 N/A N/A N/A N/A pairwise_weights N/A N/A edge N/A 0 append pw N/A N/A N/A N/A neighbors N/A N/A edge N/A 1 append N/A edge N/A 0 N/A N/A N/A N/A pairwise_weights N/A N/A edge N/A 1 append N/A pw T N/A messages_forward N/A N/A np zeros N/A n_vertices n_states N/A messages_backward N/A N/A np zeros N/A n_vertices n_states N/A pw_forward N/A N/A np zeros N/A n_vertices n_states n_states N/A traversal N/A N/A lonely 0 N/A N/A lonely n_vertices N/A N/A i N/A range lonely n_vertices N/A N/A N/A N/A visited N/A i N/A N/A queue N/A i N/A lonely N/A i 1 N/A N/A visited N/A i True N/A N/A lonely n_vertices N/A queue N/A N/A node N/A N/A queue pop 0 N/A N/A N/A traversal append node N/A N/A pw neighbor N/A zip N/A pairwise_weights N/A node N/A neighbors N/A node N/A N/A N/A N/A visited N/A neighbor N/A N/A N/A parents N/A neighbor node N/A N/A N/A queue append neighbor N/A N/A visited N/A neighbor True N/A N/A pw_forward N/A neighbor pw N/A N/A N/A N/A N/A parents N/A node neighbor N/A N/A N/A ValueError Graph not a tree N/A node N/A traversal N/A -1 N/A N/A parent N/A parents N/A node N/A N/A parent -1 N/A N/A message N/A N/A np max N/A N/A N/A messages_backward N/A node N/A unary_potentials N/A node N/A pw_forward N/A node axis 1 N/A message N/A N/A message max N/A N/A messages_backward N/A parent message N/A node traversal N/A N/A parent N/A parents N/A node N/A N/A parent -1 N/A N/A message N/A N/A N/A messages_forward N/A parent N/A unary_potentials N/A parent N/A N/A pw_forward N/A node T N/A message N/A N/A messages_backward N/A parent N/A N/A np max N/A N/A N/A messages_backward N/A node N/A unary_potentials N/A node N/A pw_forward N/A node axis 1 N/A message N/A N/A message max axis 1 N/A message N/A N/A message max N/A N/A messages_forward N/A node message N/A N/A N/A np argmax N/A N/A unary_potentials messages_forward messages_backward axis 1 N/A iterative_max_product N/A N/A unary_potentials pairwise_potentials edges max_iter damping tol N/A 10 0.5 1e-05 N/A N/A n_edges N/A len edges N/A N/A n_vertices n_states N/A unary_potentials shape N/A messages N/A N/A np zeros N/A n_edges 2 n_states N/A all_incoming N/A N/A np zeros N/A n_vertices n_states N/A i N/A range max_iter N/A N/A diff 0 N/A N/A e N/A edge pairwise N/A enumerate N/A zip edges pairwise_potentials N/A N/A update N/A N/A N/A N/A all_incoming N/A N/A edge N/A 0 N/A pairwise T N/A unary_potentials N/A N/A edge N/A 0 N/A messages N/A N/A e 1 N/A old_message N/A N/A N/A messages N/A N/A e 0 copy N/A new_message N/A N/A np max update axis 1 N/A new_message N/A N/A np max new_message N/A new_message N/A N/A damping old_message N/A N/A 1 damping new_message N/A N/A messages N/A N/A e 0 new_message N/A update N/A new_message old_message N/A N/A all_incoming N/A N/A edge N/A 1 update N/A diff N/A N/A N/A N/A np abs update sum N/A update N/A N/A N/A N/A all_incoming N/A N/A edge N/A 1 pairwise N/A unary_potentials N/A N/A edge N/A 1 N/A messages N/A N/A e 0 N/A old_message N/A N/A N/A messages N/A N/A e 1 copy N/A new_message N/A N/A np max update axis 1 N/A new_message N/A N/A np max N/A messages N/A N/A e 1 N/A new_message N/A N/A damping old_message N/A N/A 1 damping new_message N/A N/A messages N/A N/A e 1 new_message N/A update N/A new_message old_message N/A N/A all_incoming N/A N/A edge N/A 0 update N/A diff N/A N/A N/A N/A np abs update sum N/A N/A diff tol N/A N/A N/A N/A N/A np argmax N/A all_incoming unary_potentials axis 1 N/A