CMPSCI 691GM : Graphical Models
Spring 2011
Homework #4: Approximate Inference for Undirected Graphical Models

Due Dates:
Thursday April 21, 2011:   Email working source code
Tuesday April 26, 2011: Email report and revised source code

Note: In this homework we will build upon the "further fun" task from the previous homework.

In this homework assignment you will implement and experiment with new inference algorithms for loopy undirected graphical models and write a short report describing your experiences and findings. As in last homework, we will provide you with simulated "optical word recognition" data; however, you are welcome to find and use your own data instead.

OCR Model

Tree structures using Pair-skip factors

Recall from the previous assignment that the complete model score over pairs of words w1 and w2 consists of the following four classes of factors

An unfortunate consequence of these particular factors is that they can produce loopy-structures that make inference difficult (see the "further fun" section of Homework #3 for the types of loopy structures present in the data).

Fortunately, you now have new arrows in your quiver to help tackle these more complex models (e.g., mean field, loopy belief propagation, Gibbs sampling, and junction tree).

Data

We will use the dataset provided in the previous homework which can be downloaded here. Recall that the archive contains the following files:

Core Tasks (for everyone)

In the core tasks you will have the oppurtunity to implement and evaluate two inference algorithms of your choice from the following: loopy belief propagation, mean field, Gibbs sampling and exact inference (message passing in a junction tree) on the loopy structures from the dataset. You will compare these algorithms using the same evaluation metrics you used in the previous homework (the per-character and per-word accuracies from the maximum-marginal predictions). Here is a check list of the core tasks:
  1. Implement two of the following
  2. Experiments: Compare the two algorithms you implement in terms of accuracy and run time (over the three datasets) as described below. You only need to include two of the following four algorithms in your table.
    Algorithm Per-char accuracy (max marginal) Per-word accuracy (max marginal) Running time
    Exact (Junction tree + MP)
    Loopy BP
    Mean field
    Gibbs sampling

    Note that the approximate inference algorithms work in "rounds". For example, one round of Gibbs sampling is a complete sweep through each variable, one round of loopy BP is one complete execution of your message passing schedule, and mean-field updates a single variable at a time. Please discuss in your report how "long" you ran each algorithm for (plotting accuracy versus rounds will be helpful) and what stopping criteria you used. The stopping criteria could be a heuristic based on some measurement of convergence that you devise, or you might use trial-and-error to determine an appropriate number of rounds to run the algorithm. Please describe either the stopping criteria you used or the number of rounds you ran each algorithm for.

  3. Further fun: use your own creativity to further explore the space of approximate inference algorithms. Suggestions provided below.

Further Fun

  1. Implement and compare against a third inference algorithm, some suggestions are given below.
  2. Maximum a posteriori (MAP) Implement the MAP variants of the inference algorithms you chose in the core tasks. Compare the accuracy you obtain using the MAP configuration to the maximum marginals.
  3. Another task/domain: Approximate inference has allowed complex graphical models to be applied to a wide variety of problems. Apply the algorithms you implemented here to a new model on a new problem (perhaps related to your own research interests). Here is one suggestion: mean field and Gibbs sampling have been successful for inference in ising (grid) models (e.g., used for computer vision). You might want to try the following task of denoisifying a black-and-white image.
    1. Take a black and white image which we will use as the ground truth for evaluating the accuracy of our model. Next, create a noisy copy of this image by adding a small amount of random noise to each pixel (that is, randomly flip the bits of some of the pixels from a zero to one or vice-versa). The model (described below) will be designed to de-noise this image.
    2. Create an undirected model as follows. There will be two sets of binary variable types (observed x and hidden y) as well as two types of factors: one between a single observed and a single hidden variable f(x,y), and the other between two hidden variables f(y,y).

      Think of the image as a n by m grid. For each pixel p(i,j) create an observed variable x(i,j) indicating the observed value (zero/one) of that pixel. Also for each pixel create a hidden variable y(i,j) indicating the true value for that pixel. Each y(i,j) variable should be connected to its corresponding observation x(i,j) with a factor f(x,y). Intuitively, this factor should be set so that the model wants the true value of the pixel to agree with the observed value of the pixel. Finally, place a factor f(y,y) between pairs of y(i,j) variables so that Markov blanket of each y(i,j) variable has up to four variables: {y(i+1,j+1), y(i-1,j+1),y(i+1,j-1),y(i-1,j-1)}. These factors will take two hidden y's and output a compatibility score for them. Intuitively, this factor should be set to encourage neighboring pixels to have the same value.

    3. Experiment with different amounts and types of noise and try tuning the parameters of your model to denoisify the image. Evaluate accuracy (e.g., per-pixel accuracy) and report your findings.

What to hand in

The homework should be emailed to 691gm-staff@cs.umass.edu. before 5pm Eastern time on the due date.

Grading

The assignment will be graded on (a) core task completion and correctness, (b) effort and creativity in the optional extras (c) quality and clarity of your written report.

Questions?

Please ask! Send email to 691gm-staff@cs.umass.edu or come to the office hours. If you'd like your classmates to be able to help answer your question, feel free to use 691gm-all@cs.umass.edu.