Skip to content

Using Graph neural networks for probabilistic approximate inference.

License

Notifications You must be signed in to change notification settings

richardodliu/pgm_graph_inference

 
 

Repository files navigation

Inference in graphical models with GNNs

Authors: Ksenia Korovina, Lingxiao Zhao, Mark Cheung, Wenwen Si

Structure of the repo

  • graphical_models directory contains definitions of GraphicalModel class (objects abbreviated as "graphs"); graphical_models/datasets contains labeled data. Labeled graphs are stored as .npy files in the following directory structure:
graphical_models/datasets/{train/val/test}
                                |-- star/
                                |    |-  9/<file1.npy>, <file2.npy> ...
                                |    |- 10/
                                     |- 11/
                               ...  ...
  • inference directory contains all methods for performing inference on a GraphicalModel, including BP and GNN-based methods; inference/pretrained contains pretrained GNN inference procedures.
  • experiments directory contains specification for loading data (combinations of graph structures and sizes to compose training and testing) and inference experiments. If an experiment uses GNN inference, it first checks if an appropriate pretrained model exists (using train.py) by matching model postfix and train_set_name in experiment.
  • create_data.py generates graphs from user-specified arguments and saves to graphical_models/datasets by default.
  • train.py uses one of generated datasets to train a GNN inference procedure (such as GatedGNN).

Installing dependencies

The following command will install several python packages for graphs, numerical computations and deep learning:

pip install -r requirements.txt

Installation of igraph may fail under MacOS and anaconda. In this case, try setting MACOSX_DEPLOYMENT_TARGET:

MACOSX_DEPLOYMENT_TARGET=10.9 pip install graphkernels

Getting started

For imports to work correctly, add root of the repository to PYTHONPATH by running

source setup.sh

Usage

To generate data to reproduce experiments, run

bash prepare_tree_experiment.sh  # for main experiment 1

To train the GNN inference, use train.py. Finally, use ./experiments/run_exps.py to specify the way to compare a trained GNN with other inference methods.

References

ICLR18

About

Using Graph neural networks for probabilistic approximate inference.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 92.1%
  • Shell 7.9%