Automatic Differentiation of Programs with Discrete Randomness

Gaurav Arya, Moritz Schauer, Frank Schäfer, Chris Rackauckas
10/16/2022
cs.LGcs.MSmath.NA

No official code found. Best implementation: gaurav-arya/StochasticAD.jl (222 stars, Julia, MIT, last commit 2026-09-19).

Abstract

Automatic differentiation (AD), a technique for constructing new programs which compute the derivative of an original program, has become ubiquitous throughout scientific computing and deep learning due to the improved performance afforded by gradient-based optimization. However, AD systems have been restricted to the subset of programs that have a continuous dependence on parameters.

Show full abstract

Programs that have discrete stochastic behaviors governed by distribution parameters, such as flipping a coin with probability $p$ of being heads, pose a challenge to these systems because the connection between the result (heads vs tails) and the parameters ($p$) is fundamentally discrete. In this paper we develop a new reparameterization-based methodology that allows for generating programs whose expectation is the derivative of the expectation of the original program. We showcase how this method gives an unbiased and low-variance estimator which is as automated as traditional AD mechanisms. We demonstrate unbiased forward-mode AD of discrete-time Markov chains, agent-based models such as Conway's Game of Life, and unbiased reverse-mode AD of a particle filter. Our code package is available at https://github.com/gaurav-arya/StochasticAD.jl.

View on arXivView PDF

Code Implementations(1)

MIT

Research package for automatic differentiation of programs containing discrete randomness.

22220JuliaSep 17, 20222 months agoMIT

Similar Papers

Cite this paper

@article{arya2022automatic,
  title  = {Automatic Differentiation of Programs with Discrete Randomness},
  author = {Gaurav Arya and Moritz Schauer and Frank Schäfer and Chris Rackauckas},
  year   = {2022},
  eprint = {2210.08572},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2210.08572}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2210.08572.svg)](https://codeofpaper.com/paper/2210.08572)

Discussion