This package provides standard functions to create (arbitrary) undirected graphical models, using adjacency matrices.
A graph is described by an adjacency matrix, node potentials and edge potentials.
Four common tasks are implemented:
-
Decoding: finding the joint configuration of the variables with the highest joint probability;
-
Inference: computing the normalization constant Z (partition function), as well as the probabilities of each variable taking each possible state (the marginal probabilities);
-
Sampling: given a model, sampling generates likely configurations for each node of the graph;
-
Training (or parameter estimation): the task of computing the potentials that maximize the likelihood of a set of data (MAP estimation).
Note 1: parameter estimation is implemented for CRF and MRF objectives.
Note 2: this code is heavily based on UGM, from Mark Schmidt.
$ [sudo] luarocks install gm
First run torch, and load gm:
$ th
> require 'gm'
Once loaded, see and run the examples:
> gm.examples.simple()
> gm.examples.trainMRF()
> gm.examples.trainCRF()