The Semantics of Subroutines and Iteration in the Bayesian Programming Language Probt
Total Page:16
File Type:pdf, Size:1020Kb
1 The semantics of Subroutines and Iteration in the Bayesian Programming language ProBT R. LAURENT∗, K. MEKHNACHA∗, E. MAZERy and P. BESSIERE` z ∗ProbaYes S.A.S, Grenoble, France yUniversity of Grenoble-Alpes, CNRS/LIG, Grenoble, France zUniversity Pierre et Marie Curie, CNRS/ISIR, Paris, France Abstract—Bayesian models are tools of choice when solving 8 8 8 problems with incomplete information. Bayesian networks pro- > > >Variables > > <> vide a first but limited approach to address such problems. > <> Decomposition <> Specification (π) For real world applications, additional semantics is needed to Description > P arametric construct more complex models, especially those with repetitive > :>F orms > > P rogram structures or substructures. ProBT, a Bayesian a programming > :> > Identification (based on δ) language, provides a set of constructs for developing and applying :> complex models with substructures and repetitive structures. Question The goal of this paper is to present and discuss the semantics associated to these constructs. Figure 1. A Bayesian program is constructed from a Description and a Question. The Description is given by the programmer who writes a Index Terms—Probabilistic Programming semantics , Bayesian Specification of a model π and an Identification of its parameter values, Programming, ProBT which can be set in the program or obtained through a learning process from a data set δ. The Specification is constructed from a set of relevant variables, a decomposition of the joint probability distribution over these variables and a set of parametric forms (mathematical models) for the terms I. INTRODUCTION of this decomposition. ProBT [1] was designed to translate the ideas of E.T. Jaynes [2] into an actual programming language. ProBT A. Description was defined around the year 2000 [3], [4] and it has been The purpose of a description is to specify an effective 1 maintained and further developed since then . ProBT is one method for computing a joint probability distribution on a set of the first probabilistic programming languages (as e.g. [5], of N variables fX1;X2; ··· ;XN g given a set of experimental [6]), designed to specify stochastic inferences as Bayesian pro- data δ and some specification π. This joint distribution is grams. It includes an exact inference engine as well as several denoted as: P (X1 ^ X2 ^ · · · ^ XN jδ ^ π). MCMC methods for approximate inferences [4]. The ProbaYes company has been using ProBT for 13 years in industrial B. Specification applications ranging from driving assistance to optimization To specify preliminary knowledge, the programmer must go of the energy consumption in buildings. With the same goals through the following three steps. as [7], recent advances include prototyping dedicated hardware [8]–[10] to interpret ProBT programs. 1) Define the set of relevant variables fX1;X2; ··· ;XN g Early robotic experiments [11] revealed the need for prob- on which the joint probability distribution is defined. abilistic submodels; they also pointed out the importance of 2) Decompose the joint probability distribution. The pro- correctly specifying Bayesian filters. In this paper we present grammer defines the structure of a complex probabilistic the semantics of two constructs found in ProBT to define model by combining simpler terms: priors and condi- stochastic submodels and filters. tional probability distributions describing the probabilis- tic dependences between the considered variables. Formally, the programmer chooses a partition of II. A BRIEF OVERVIEW OF PROBT fX1;X2; ··· ;XN g into K subsets, defined by the K variables L1; ··· ;LK where each variable Lk is the We define a Bayesian program as a means of specifying conjunction of the variables fXk1 ;Xk2 ; · · · g belonging some knowledge structured as a probabilistic model, to which to the kth subset. The conjunction rule then leads to the the programmer asks a question (or probabilistic query) to following decomposition: solve a task, which will be answered to by means of probabilis- tic inference. The constituent elements of a Bayesian program P (X ^ X ^ · · · ^ X jδ ^ π) are presented figure 1. 1 2 N = P (L1jδ ^ π) × P (L2jL1 ^ δ ^ π) (1) × · · · × P (LK jLK−1 ^ · · · ^ L1 ^ δ ^ π) 1A free version of ProBT is available for academic use at http: //www.probayes.com/fr/Bayesian-Programming-Book/downloads/. 3) Define the forms: 2 For each term of the decomposition (equation 1), the programmer chooses a parametric form (i.e., a math- 8 8 8 St; 8t 2 [0;:::;T ]: St 2 D > > >V a : S ematical function fµ (Lk)) or defines it as a question > > > Ot; 8t 2 [1;:::;T ]: Ot 2 D > > > O to another Bayesian program. In general, µ is a vector > > > (P S0 ^ O1;:::St ^ Ot :::ST ^ OT = > > > of parameters that may depend on the conditioning > > >Dc : t2[1:::T ] > < < 0 Q t t−1 t t variables, on δ, or both. Learning takes place when some <>Ds Sp P S P S j S P O j S P r 8 0 of these parameters are computed using the data set δ. > > <P S = Initial condition > > > t t−1 > > >F o : P S j S = Transition Model > > > : t t > > > P O j S = Sensor Model C. Questions > :> :> > Id : learning from δ :> T 1 T Given a description (i.e., P (X1 ^ X2 ^ · · · ^ XN jδ ^ π)), Qu : P S j o : : : o the programmer defines a question by partitioning (4) fX1;X2; ··· ;XN g into three sets: the searched variables, the known variables, and the free variables. The variables The question of the Bayesian program shown in Equation 4 Searched, Known, and Free are defined as the conjunctions can be adapted to address several interesting tasks: T 1 T of the variables belonging to these sets. The question is • Filtering: P S j o : : : o : the purpose of this question defined as the set of distributions is to infer the current state according to the past sequence of measurements. k 1 k T P (SearchedjKnown ^ δ ^ π) ; (2) • Smoothing: P S j o : : : o : : : o estimates a past state of the system by taking into account more recent which comprises as many “instantiated questions” as there measurements (k < T ). are possible values known for the conjunction Known, each T 1 k • Forecasting: P S j o : : : o estimates the state of the instantiated question being the probability distribution system in the future based on the current measurements P (Searchedjknown ^ δ ^ π) : (3) (T > k). V. APPLICATIONS III. BAYESIAN SUBROUTINES To illustrate the semantics of the proposed constructs we ProBT allows to build incrementally more and more sophis- will detail two robotics applications. How to program a ticated probabilistic models by combining several Bayesian complex task with Bayesian subroutines: the night watchman programs. Indeed, some of the terms of the decomposition task for a mobile robot; and how to program classical Hidden of a Bayesian program can be defined as calls to Bayesian Markov Models (HMM) for motion recognition with a generic subroutines (i.e. other Bayesian programs). It follows that, Bayesian filter. as in standard programming, it is possible to use existing probabilistic models to build more complex ones and to further REFERENCES structure the definition of complex descriptions by reusing [1] P. Bessiere,` E. Mazer, J. M. Ahuactzin, and K. Mekhnacha, Bayesian some previously defined models. programming. CRC Press, 2013. [2] E. T. Jaynes, Probability Theory: The Logic of Science. Cambridge There are several advantages to Bayesian programming University Press, Apr. 2003. subroutine calls: (i) as in standard programming, subroutines [3] O. Lebeltel, “Programmation bayesienne´ des robots,” These` de doctorat, make the code more compact and easier to read; (ii) as Institut National Polytechnique de Grenoble, Grenoble, France, 1999. [4] K. Mekhnacha, J.-M. Ahuactzin, P. Bessiere,` E. Mazer, and L. Smail, in standard programming the use of a submodel allows to “Exact and approximate inference in ProBT,” Revue d’Intelligence hide the details regarding the definition of this model; (iii) Artificielle, vol. 21/3, pp. 295–332, 2007. calling subroutines gives the ability to use Bayesian programs [5] N. Goodman, V. Mansinghka, D. Roy, K. Bonawitz, and J. Tenenbaum, “Church: A language for generative models,” in Proceedings of the 24th that have been specified and learned by others; (iv) contrary Conference on Uncertainty in Artificial Intelligence (UAI), 2008, pp. to standard function calls, since Bayesian subroutines are 220–229. probabilistic, they do not transmit to the calling code a single [6] V. Mansinghka, D. Selsam, and Y. Perov, “Venture: a higher-order prob- abilistic programming platform with programmable inference,” arXiv value but a whole probability distribution. preprint arXiv:1404.0099, 2014. [7] E. M. Jonas, “Stochastic architectures for probabilistic computation,” Ph.D. dissertation, Massachusetts Institute of Technology, 2014. IV. ITERATIONS IN GENERIC BAYESIAN FILTERS [8] M. Faix, E. Mazer, R. Laurent, M. Othman Abdallah, R. Le Hy, and J. Lobo, “Cognitive computation: A bayesian machine case study,” in Often a sequence of measurements helps to better char- Cognitive Informatics Cognitive Computing (ICCI*CC), 2015 IEEE 14th acterize the state of a system. Bayesian filters serve this International Conference on, 2015, pp. 67–75. purpose. They may be seen as special cases of dynamic [9] A. Coninx, R. Laurent, M. A. Aslam, P. Bessiere,` J. Lobo, E. Mazer, and J. Droulez, “Bayesian Sensor Fusion with Fast and Low Power Bayesian networks and are often used to process time series of Stochastic Circuits,” in IEEE 1st International Conference on Rebooting sensor readings. The following program (Equation 4) defines Computing, 2016. a generic Bayesian filter, for which the inference solving the [10] M. Faix, R. Laurent, P. Bessiere,` E. Mazer, and J. Droulez, “Design of Stochastic Machines Dedicated to Approximate Bayesian Inferences,” question will iterate a simple computation on two building Transactions on Emerging Topics in Computing, 2016. blocks: a transition model P St j St−1 and a sensor model [11] S.