Code Monkey home page Code Monkey logo

torch_mrf's Introduction

Welcome to Markov Random Fields in PyTorch

This package provides a vectorized implementation of Markov Random Fields that is capable of GPU acceleration.

The packages can be installed by navigating to the torch_random_variable folder and calling pip install . there. After that pip install . should be called in the directory above.

The theory behind MRFs is best understood through the book "Probabilistic Graphical Models" by Daphne Koller and Nir Friedmann. The book can be found for free under this link https://djsaunde.github.io/read/books/pdfs/probabilistic%20graphical%20models.pdf .

In examples/mnist_mn.py an example can be found that shows the interface to the torch_mrf package.

The example performs classification on the MNIST handwritten digit dataset. The structure of the MRF is a logistic regression like structure.

Complexity Discussion

It is commonly known that MRFs are exponential hard due to the calculation of the partition function. To become even worse the partition function is also part of the derivative of the log-likelihood of an MRF and therefore training was known to be unfeasible until today. This MRF implementation exploits the intuitive explanation of cliques. Cliques represent the relative potential that is associated with a scenario. For example the potentials \phi(A,B) = 5 and \phi(A,!B) = 10 state that A and not B is twice as likely as A and B. Therefore the cliques are optimal if the represent the joint probability distribution of their variables. The parameters can be found via probabilistic inference on the data. This procedure takes O(N^2 * |\phi|) steps and is therefore suitable for large problems. The calculation Z can be avoided in almost every AI scenario. AI scenarios almost ever contain a question of which world is more likely. The outputs for the probabilities of the worlds of an MRF are all distorted by the factor 1/Z. This distortion can be ignored in comparing scenarios. To conclude this repository provides MRFs that can be fit in quadratic time and where inference is done in linear time.

torch_mrf's People

Contributors

tomsch420 avatar mir7b avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.