# Generative Neuro-Symbolic (GNS) Modeling


## Setup

This code repository requires Python 3 with PyTorch. We recommend using PyTorch >= 1.5.0, as this version was used for development and testing.

In order to use the provided sources code modules, make sure to add the GNS-Modeling root folder to your python path (Unix machines):
 ```
export PYTHONPATH="/path/to/GNS-Modeling:$PYTHONPATH"
```

The code has a few key requirements:

1. MATLAB & [MATLAB Engine API for Python](https://www.mathworks.com/help/matlab/matlab-engine-for-python.html)
2. [BPL matlab package](https://github.com/brendenlake/BPL)
3. [pyBPL python package](https://github.com/rfeinman/pyBPL)

Note that 1 & 2 are only required to run the bottom-up parser during inference. The full generative model, and all other functions, can be used with only #3.


## Running Experiments

After completing the setup steps above, navigate to the `experiments/` directory to find scripts for running our experiments with the GNS model. Each experiment has its own unique sub-directory and a README with directions for running the experiment scripts.
