1 of 38

Introduction to Deep Probabilistic Programming with Pyro

柯維然 Odie

2 of 38

Outline

  1. Probabilistic Programming
  2. Pyro tutorial
  1. Realworld example

3 of 38

Probabilistic Programming

Deep learning

Bayesian learning

Graphical model

Logic/Rule based

Domain knowledge

Handcrafted features

4 of 38

Probabilistic Programming

  • 3 AI paradigms
    • Symbolic: logic and reasoning
    • Bayesian: Inference and uncertainty
    • Connetion: learning from complicated data
  • Probabilistic Programming combine them !

5 of 38

Intuition

  • Parameters
  • Latent variables

Program

Output / Sample

  • Input
  • Configuration

Program

Output

  • Parameters
  • Latent variables

Program

Data / Observation

Probabilistic Programming

Sampling

Inference

6 of 38

Human-level concept learning through probabilistic program induction

7 of 38

Build, Compute, Critique, Repeat

8 of 38

Pyro

  • Pyro bulit on Pytorch and another version on JAX (NumPyro)
  • Support GPU and JIT mode
  • Flexible and minimal design
  • Focus on stochastic variational inference

9 of 38

Temperature-Sensor Model

10 of 38

Sampling

  • Repeat testing can generate many sample

11 of 38

Trace

model arguments

12 of 38

Evaluation probability

  • Fix sampled value in model function
  • Return new trace

13 of 38

Evidence Lower Bound

  • Maximize the ELBO
  • Minimize KL

Define the generative model

Define the guide model

14 of 38

Monte Carlo ELBO

Define the generative model

Define the guide model

15 of 38

Define model & guide

Obs is i.i.d !

16 of 38

SVI

Pyro implement several ELBO object function , will have lower variance

Use navie ELBO or custom implementation

17 of 38

Training & result

Posterior : temp ~ N(13,8661 , 0.1686)

Prior : temp ~ N(0 , 1)

Real data : temp ~ N(15 , 10)

18 of 38

Take home …

SVI

Model , Guide

Prior

19 of 38

Gaussian Mixture Model

Z

X

locs

Scales

Weight

N

plate

K

20 of 38

Define model

Marginalized discrete RV in SVI

MLE

Gaussian component prior

21 of 38

Define guide & training

Auto generate guide function for point estimation

Enumerate discrete RV

22 of 38

Result

K=16

K=8

23 of 38

Generate new data

K=16

K=8

Fix locs and scales from guide_trace , then resample x

24 of 38

Latent Dirichlet Allocation

  • Elegant model
  • Need Gibbs sampling
  • Hard to scale up

25 of 38

Generate data

Sequential not vectorized

26 of 38

Define model

27 of 38

Define guide

mini batch training

28 of 38

Topic result

29 of 38

Variational Autoencoders

  • Pyro official tutorial

30 of 38

Unsupervised object detection

pos

B*H*W*N

logit

B*4*4*2

Yolo like model

31 of 38

Unsupervised object detection

Model definition

differential image render

32 of 38

Differential image render

Spatial transformer networks

Transform pos and logit

33 of 38

Result

use point estimation guide

use CNN guide and more object

34 of 38

35 of 38

36 of 38

Conclusion

  • Probabilistic Programming Language is future of AI
  • Unsupervised learning , self-supervised learning , generative model , causal inference , uncertainty , bayesian neural networks ...
  • Challenge:
    • Discreate RV learning and inference (VI is not good for discreate RV)
    • New tools and algorithm combine AD system (Julia Gen)
    • Solve real world task

37 of 38

Refernece & Resource

38 of 38

Q&A

Thanks for listening