Many machine learning problems involves loss function that contains random variables. To perform backpropagation, estimating gradient of the loss function is required.


This paper tried to formalize the computation of gradient of loss function with computation graphs. Assume we want to compute . There are two differnt way that random variable x can be influenced by .

  1. Score Function Estimator
    If probability distribution is parametrized by , the gradient can be estimated with score function estimator.

    Score function extimator is also known as likelihood ratio estimator, or REINFORCE.
  2. Pathwise derivative
    If x is deterministically influenced by another random variable z which is influenced by the gradient can be estimated with pathwise derivative.

    If appear both in the probability distribution and inside expectation,

    To formallize this with directed acyclic graph, this paper represent deterministic nodes with squares and stochastic nodes with circles. image Some example can be shown as below. image Further notation can be defined as below. image Given differentiability requirements hold, the gradient of sum of costs can be represented as two equivalent equations. image This paper suggest surrogate loss function which convert the stochastic graphs to deterministic graphs from equation above.
    To reduce the variance of score function estimator we can subtract the baseline estimate of the function. image Algorithm is as below. image


Great summary and clean formalation of getting gradient of function with stochatic variables.

Schulman, John, et al. “Gradient estimation using stochastic computation graphs.” Advances in Neural Information Processing Systems. 2015.