alex.ml.bn package

Submodules

alex.ml.bn.autopath module

self cloning, automatic path configuration

copy this into any subdirectory of pypy from which scripts need to be run, typically all of the test subdirs. The idea is that any such script simply issues

import autopath

and this will make sure that the parent directory containing “pypy” is in sys.path.

If you modify the master “autopath.py” version (in pypy/tool/autopath.py) you can directly run it which will copy itself on all autopath.py files it finds under the pypy root directory.

This module always provides these attributes:

pypydir pypy root directory path this_dir directory where this autopath.py resides

alex.ml.bn.factor module

alex.ml.bn.lbp module

Belief propagation algorithms for factor graph.

class alex.ml.bn.lbp.BP[source]

Bases: object

Abstract class for Belief Propagation algorithm.

run()[source]

Run inference algorithm.

exception alex.ml.bn.lbp.BPError[source]

Bases: exceptions.Exception

class alex.ml.bn.lbp.LBP(strategy='sequential', **kwargs)[source]

Bases: alex.ml.bn.lbp.BP

Loopy Belief Propagation.

LBP is an approximative inference algorithm for factor graphs. LBP works with generic factor graphs. It does accurate inference for trees and is equal to sum-product algorithm there.

It is possible to specify which strategy should be used for choosing next node for update. Sequential strategy will update nodes in exact order in which they were added. Tree strategy will assume the graph is a tree (without checking) and will do one pass of sum-product algorithm.

add_layer(layer)[source]
add_layers(layers)[source]

Add layers of nodes to graph.

add_nodes(nodes)[source]

Add nodes to graph.

clear_layers()[source]
clear_nodes()[source]
init_messages()[source]
run(n_iterations=1, from_layer=None)[source]

Run the lbp algorithm.

exception alex.ml.bn.lbp.LBPError[source]

Bases: alex.ml.bn.lbp.BPError

alex.ml.bn.node module

alex.ml.bn.test_factor module

alex.ml.bn.test_lbp module

alex.ml.bn.test_node module

alex.ml.bn.utils module

Module contents