SlideShare a Scribd company logo
Introduction to Probabilistic
Programming with Pyro
Ahmad Salim Al-Sibahi
Is this a cat or a dog?
Could be worse. Not sure
how, but it could be.
CC BY Kassy at SketchPort
Disposition
● What is probabilistic programming?
● Probabilistic models in Pyro
● Techniques for Bayesian Inference
Probabilistic Programming
is Machine Learning...
It is all about inference!
Inference is answering questions about data!
Image
Observed Data (d)
Cat or
Dog?
Category
Latent Variable (𝛉)
Inference is answering questions about data!
Sequence of Amino Acids Folded Structure
Observed Data (d) Latent Variable (𝛉)
Inference is answering questions about data!
Voucher
Observed Data (d)
Payment Information
Latent Variable (𝛉)
Sender: Asterix SARL
Recipient: Hamlet-Kierkegaard ApS
Issue Date: April 1st 2015
Total Amount: EUR 98,691.00
Modelling as joint distributions
p(d,𝛉)
Traditional Inference
ℓ(𝛉’|d) ∝ p(d, 𝛉’)
Find 𝛉’ maximizing
likelihood:
Traditional Inference
ℓ(𝛉’|d) ∝ p(d| 𝛉’)
Find 𝛉’ maximizing
likelihood:
Limitations
● Only a single value is given as output 𝛉’
● Not possible to incorporate domain knowledge
● Deep neural networks are not humanly interpretable and require lots of data
Bayesian Inference
p(𝛉|d) ∝ p(d, 𝛉)
Find probability distribution
Bayesian Inference
p(𝛉|d) ∝ p(d|𝛉)p(𝛉)
Find probability distribution
Bayesian inference allows quantification of uncertainty
Probabilistic Programming Language Frameworks
i
HackPPL - Facebook
Pyro - Uber and Linux Foundation
TensorFlow Probability - Google
Infer.Net - Microsoft
PyMC3 - NumFOCUS
Probabilistic Programming with
Pyro
Logistic Regression
● Given height and weight
of person, then infer
whether male or female
● Use logistic regression!
Bayesian Logistic Regression
Techniques for Bayesian Inference
The challenge of inference
p(𝛉|d) ∝ p(d|𝛉)p(𝛉)
The challenge of inference
p(𝛉|d) =
p(d|𝛉)p(𝛉)
p(d)
The challenge of inference
p(𝛉|d) =
p(d|𝛉)p(𝛉)
∫𝛉 p(d|𝛉)
Can be arbitrarily complex
(Multi-modal, saddlepoints, discontinuous)
Often
intractable
PreciseApproximate
Fixed
Flexible
Symbolic
Disintegration
Sampling
Message Passing
Variational Inference
Variational Inference
● Posit a guide q(θ;λ) to approximate
posterior p(θ|d)
● Find optimal λ’ so that q(θ;λ’) has a good
fit w.r.t. p(θ|d)
Stochastic Variational Inference (Hoffman et al. 2013)
● Minimize exclusive divergence by maximizing ELBO:
KL(q(θ;λ)|| p(θ|d)) = log p(d|θ) - ELBO
● ELBO can be estimated by stochastic sampling of parameters
ELBO = E[log q(θ;λ) - log p(d,θ)]
● Optimization works well if samples have low variance
○ Relies on tricks like reparametrization, dependency structure handling and
Rao-Blackwellization
Amortized Inference (Ritchie et al. 2016)
● Assume that guide can be factorized into local and global parameters:
q(θ;λ) = q(θG;λG) ∏i q(θi;λi, λG)
● Learn a function f that maps local parameters from data
q(θ|d;λ) = q(θG;λG) ∏i q(θi;f(di), λG)
● The function f can be a deep neural network!
Reflections on Variational Inference
Pros
● Work with expressive
probabilistic programming
models
● Quantifies uncertainty
● Scalable to large datasets
Cons
● Discrete variables can introduce
high variance
● Can be over-confident in
prediction
● No guarantees on approximation
correctness
Sampling
● Estimate posterior p(θ|d) by
drawing many high-probability
samples of parameters θ1, …, θn
● Samples can be proposed by
custom distribution q(θ) and
accepted when p(θi|d) is
sufficiently high
Hamiltonian Monte Carlo (Duane et al. 1987)
● Markov chain Monte Carlo-based
● Relies on gradient information
● No U-Turn Sampler (NUTS)
allows automated step-size
adaptation (Hoffman and
Gelman 2011)
θ0 θ1 θ2 θ3
Animation https://chi-feng.github.io/mcmc-demo/
Reflections on Sampling
Pros
● Most flexible technique for
inference
● Captures precise correlations
between parameters
● Provides precise
characterization of true posterior
with enough samples
Cons
● Not efficiently scalable to large
datasets
● Sensitive to landscape of true
posterior distribution
● Latent variables can pose a
problem for differentiation
Wrapping up
Probabilistic Programming
● Probabilistic Programming is important because it allows
incorporating domain knowledge and quantifying
uncertainty
● Pyro allows specifying both classical and deep
probabilistic models
● Modern inference algorithms are very powerful, and easily
accessible in Pyro
Hands-on

More Related Content

PDF
Continual Learning Introduction
PDF
Continual Learning: why, how, and when
PDF
The Impact of Artificial Intelligence and Digital Disruption on the Supply Chain
PDF
Agents for Enterprise Workflows - Berkeley LLM AI Agents MOOC
PDF
What it means to be educated in 2050
PPTX
PCA Final.pptx
PDF
Continual learning: Survey
PDF
Continual Learning with Deep Architectures - Tutorial ICML 2021
Continual Learning Introduction
Continual Learning: why, how, and when
The Impact of Artificial Intelligence and Digital Disruption on the Supply Chain
Agents for Enterprise Workflows - Berkeley LLM AI Agents MOOC
What it means to be educated in 2050
PCA Final.pptx
Continual learning: Survey
Continual Learning with Deep Architectures - Tutorial ICML 2021

What's hot (8)

PPTX
MACHINE LEARNING PRESENTATION (ARTIFICIAL INTELLIGENCE)
PDF
Let's talk about GPT: A crash course in Generative AI for researchers
PDF
Notes from Coursera Deep Learning courses by Andrew Ng
PDF
Large Language Models - Chat AI.pdf
PDF
Ai black box
PDF
Prompt-Engineering-Lecture-Elvis learn prompt engineering
PPT
Machine Learning
PDF
Multimodal Deep Learning
MACHINE LEARNING PRESENTATION (ARTIFICIAL INTELLIGENCE)
Let's talk about GPT: A crash course in Generative AI for researchers
Notes from Coursera Deep Learning courses by Andrew Ng
Large Language Models - Chat AI.pdf
Ai black box
Prompt-Engineering-Lecture-Elvis learn prompt engineering
Machine Learning
Multimodal Deep Learning
Ad

Similar to Introduction to probabilistic programming with pyro (20)

PDF
20180722 pyro
PDF
Bayesian Deep Learning
PDF
Introduction to modern Variational Inference.
PDF
Probabilistic modeling in deep learning
PPTX
Bayesian Neural Networks
PDF
Probabilistic AI Lecture 1: Introduction to variational inference and the ELBO
PDF
An Importance Sampling Approach to Integrate Expert Knowledge When Learning B...
PDF
Accelerating Metropolis Hastings with Lightweight Inference Compilation
PDF
Deep VI with_beta_likelihood
ODP
Gentle Introduction: Bayesian Modelling and Probabilistic Programming in R
PDF
Pyro Primer
PDF
Variational Inference in Python
PPTX
Machine Learning Algorithms Review(Part 2)
PDF
Modeling uncertainty in deep learning
PPTX
Lecture 6 of probabilistic modellin.pptx
PDF
is anyone_interest_in_auto-encoding_variational-bayes
PDF
Variational Bayes: A Gentle Introduction
PPTX
Deep generative learning_icml_part1
PDF
Ph.D. Dissertation Defense
PDF
Uncertainty in deep learning
20180722 pyro
Bayesian Deep Learning
Introduction to modern Variational Inference.
Probabilistic modeling in deep learning
Bayesian Neural Networks
Probabilistic AI Lecture 1: Introduction to variational inference and the ELBO
An Importance Sampling Approach to Integrate Expert Knowledge When Learning B...
Accelerating Metropolis Hastings with Lightweight Inference Compilation
Deep VI with_beta_likelihood
Gentle Introduction: Bayesian Modelling and Probabilistic Programming in R
Pyro Primer
Variational Inference in Python
Machine Learning Algorithms Review(Part 2)
Modeling uncertainty in deep learning
Lecture 6 of probabilistic modellin.pptx
is anyone_interest_in_auto-encoding_variational-bayes
Variational Bayes: A Gentle Introduction
Deep generative learning_icml_part1
Ph.D. Dissertation Defense
Uncertainty in deep learning
Ad

Recently uploaded (20)

PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
System and Network Administration Chapter 2
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PDF
Nekopoi APK 2025 free lastest update
PPTX
Transform Your Business with a Software ERP System
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PDF
AI in Product Development-omnex systems
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PDF
Digital Strategies for Manufacturing Companies
PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PPTX
Introduction to Artificial Intelligence
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PDF
System and Network Administraation Chapter 3
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
Design an Analysis of Algorithms I-SECS-1021-03
2025 Textile ERP Trends: SAP, Odoo & Oracle
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
CHAPTER 2 - PM Management and IT Context
System and Network Administration Chapter 2
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
Nekopoi APK 2025 free lastest update
Transform Your Business with a Software ERP System
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
AI in Product Development-omnex systems
Which alternative to Crystal Reports is best for small or large businesses.pdf
Digital Strategies for Manufacturing Companies
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
Introduction to Artificial Intelligence
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
System and Network Administraation Chapter 3
Internet Downloader Manager (IDM) Crack 6.42 Build 41
Lecture 3: Operating Systems Introduction to Computer Hardware Systems

Introduction to probabilistic programming with pyro