Skip to main content

Neural Probabilistic Programs (NeuralPPs)

Project description

Neural Probabilistic Programs (NeuralPPs)

This is an implementation of graphical models inference (Variable Elimination) using PyTorch for implementing factors (conditional probabilities and priors). Those can be implemented as tables (the typical discrete graphical model implementation) but also as arbitrary PyTorch modules, the case of most interest being of course neural networks.

The reason we are calling it "probabilistic programs" even though we only have discrete graphical models so far is that factors and variables are implemented in a manner general enough for probabilistic programming symbolic implementations be introduced down the road.

Purpose

This project is for researchers interested in exploring the connection between probabilistic and neural network inference. It is a library that provides the utilities for mixing neural networks and graphical models while offering GPU use and stochastic gradient descent training.

Content

This repository contains:

  • source code, including an experiments directory
  • test code (to be run with PyTest)
  • setup.py for installing with Pip
  • environment.yml for importing a Conda environment

Installation

PyPI

The library can be installed with

pip install neuralpp

Installation from source

First, clone the repo locally:

git clone https://github.com/rodrigodesalvobraz/neuralpp.git
cd neuralpp

Then, to install a developer copy, run:

python setup.py develop

Alternatively, for a regular installation:

python setup.py install

Experiments

In src/experiments one can find src/experiments/simple_mnist.py, which shows how to use a "graphical model" with a single factor, implemented by a convolutional neural network, to learn how to recognize MNIST digits.

In src/experiments/successive_digits.py there is code for training a MNIST recognizer from pairs of images of digits, labeled as being successive digits (positive examples) or not (negative examples). The correct digit labels are still learned in spite of a total absence of digit labels. This is possible due to the reasoning performed by the graphical model component of the model (based on the knowledge of what successive digits are).

In src/experiments/sum_of_pair.py pairs of images are labeled by the sum of their corresponding digits. Again the reasoning aspect of graphical models helps by using knowledge about addition.

Tests

Tests in neuralpp.test are split into quick_tests and slow_tests. The former include tests of basic data structure implementations while the latter includes learning sessions with stochastic gradient descent and take several minutes.

Run them with pytest . from the root directory if installed from the source code.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

neuralpp-0.1.1.tar.gz (72.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

neuralpp-0.1.1-py3-none-any.whl (109.0 kB view details)

Uploaded Python 3

File details

Details for the file neuralpp-0.1.1.tar.gz.

File metadata

  • Download URL: neuralpp-0.1.1.tar.gz
  • Upload date:
  • Size: 72.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8

File hashes

Hashes for neuralpp-0.1.1.tar.gz
Algorithm Hash digest
SHA256 30cb3b64014462335873f3a8e39501f4f79623dfc1ac321d2e39f070148aa376
MD5 6a8f6394e0a2604a517559a9441ceaf2
BLAKE2b-256 fd058e8d81dea82dd190875b515cd2eb8dc0ee6ce1a415ad25c25f84d33094ff

See more details on using hashes here.

File details

Details for the file neuralpp-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: neuralpp-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 109.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8

File hashes

Hashes for neuralpp-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ab52ce3c4387a868e28a4e9fb5db4cf472ed46661f78300e76fcc06d52a654d0
MD5 94b033e4f39ce3b961b9ae6a465f1f4e
BLAKE2b-256 463a5b85e0450c35539aca4feca92142ad61f6a065164f6e1daf42cc9662b97e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page