This is a Leiningen project containing several example probabilistic programs for compiled inference. Check out the main project page and a more detailed tutorial.
- Gaussian
- Gaussian Mixture Model with fixed number of clusters
- Gaussian Mixture Model with variable number of clusters
- Wikipedia's Captcha
- Facebook's Captcha
- Gorilla REPL Notebooks
This is a minimal example used to test if everything is running.
Start the compilation server:
lein run -- \
--mode compile \
--namespace queries.gaussian
Then run the following to train the neural network:
python -m pyprob.compile
Start the inference server:
python -m pyprob.infer
Then run inference:
lein run -- \
--mode infer \
--namespace queries.gaussian \
--infer-query-args-value [2.3] \
--infer-number-of-samples 10
Compiled artifact for this probabilistic program was used to produce plots in Figure 4 in the paper.
Start the compilation server:
lein run -- \
--mode compile \
--namespace queries.gmm-fixed-number-of-clusters \
--compile-combine-observes-fn combine-observes-fn \
--compile-combine-samples-fn combine-samples-fn \
--compile-query-args-value "[$(python src/helpers/io/csv2edn.py resources/gmm-data/gmm.csv) {:mu-0 [0 0] :Sigma-0 [[0.1 0] [0 0.1]]}]"
Then run the following to train the neural network:
python -m pyprob.compile \
--obsEmb cnn2d6c \
--obsEmbDim 20 \
--lstmDim 20 \
Start the inference server:
python -m pyprob.infer
Then run inference:
lein run -- \
--mode infer \
--namespace queries.gmm-fixed-number-of-clusters \
--infer-observe-embedder-input-value "$(python src/helpers/io/csv2hst.py resources/gmm-data/gmm.csv)" \
--infer-query-args-value "[$(python src/helpers/io/csv2edn.py resources/gmm-data/gmm.csv) {:mu-0 [0 0] :Sigma-0 [[0.1 0] [0 0.1]]}]"
Compiled artifact for this probabilistic program was used to produce plots in Figure 2 in the paper.
Start the compilation server:
lein run -- \
--mode compile \
--namespace queries.gmm-variable-number-of-clusters \
--compile-combine-observes-fn combine-observes-fn \
--compile-combine-samples-fn combine-samples-fn \
--compile-query-args-value "[$(python src/helpers/io/csv2edn.py resources/gmm-data/gmm.csv) {:mu-0 [0 0] :Sigma-0 [[0.1 0] [0 0.1]]}]"
Then run the following to train the neural network:
python -m pyprob.compile \
--obsEmb cnn2d6c \
--obsEmbDim 256 \
--lstmDim 256
Start the inference server:
python -m pyprob.infer
Then run inference:
lein run -- \
--mode infer \
--namespace queries.gmm-variable-number-of-clusters \
--infer-observe-embedder-input-value "$(python src/helpers/io/csv2hst.py resources/gmm-data/gmm.csv)" \
--infer-query-args-value "[$(python src/helpers/io/csv2edn.py resources/gmm-data/gmm.csv) {:mu-0 [0 0] :Sigma-0 [[0.1 0] [0 0.1]]}]"
The code and data for clustering detector hits of images from the PASCAL VOC 2007 dataset to reproduce Figure 2 of the paper are in examples/plots/gmm-variable-number-of-clusters/detector-hits-clustering. We used Hakan Bilen's and Abhishek Dutta's MatConvNet implementation of the Fast R-CNN detector. We are very grateful to Hakan for showing us how to use their code.
Compiled artifact for this probabilistic program was used to break Wikipedia's Captcha, which was described in Section 4.2 of the paper.
Start the compilation server:
lein run -- \
--mode compile \
--namespace queries.captcha-wikipedia
Then run the following to train the neural network:
python -m pyprob.compile \
--obsEmb cnn2d6c \
--obsEmbDim 1024 \
--lstmDim 512
Start the inference server:
python -m pyprob.infer
Then run inference:
lein run -- \
--mode infer \
--namespace queries.captcha-wikipedia \
--infer-query-args-value "[$(python src/helpers/io/png2edn.py resources/wikipedia-dataset/agavelooms.png)]"
Compiled artifact for this probabilistic program was used to break Facebook's Captcha, which was described in Section 4.2 of the paper.
Start the compilation server:
lein run -- \
--mode compile \
--namespace queries.captcha-facebook
Then run the following to train the neural network:
python -m pyprob.compile \
--obsEmb cnn2d6c \
--obsEmbDim 1024 \
--lstmDim 512
Start the inference server:
python -m pyprob.infer
Then run inference:
lein run -- \
--mode infer \
--namespace queries.captcha-facebook \
--infer-query-args-value "[$(python src/helpers/io/png2edn.py resources/facebook-dataset/2MsLet.png)]"
Gorilla REPL is a Jupyter-like, notebook-style Clojure REPL. All above examples have a corresponding Gorilla REPL version. To open the notebooks, run
lein gorilla
and open the link shown. To load a worksheet, click the button on the top-right corner and select Load a worksheet. Then, use Shift+Enter to successively evaluate the code blocks.