Code for Piecewise Linear/Quadratic Bounds to the log(1+exp(x))

Back to Home or Software

Written by Emtiyaz, CS, UBC.
Last updated: Nov. 15, 2011.
Update on May 1, 2012: Matt Hoffman wrote a version of the code in Python [ Download ]

Description: This matlab code can be used to compute an upper bound to expectation of log(1+exp(x)) with respect to a Gaussian disctribution. These bounds can be used to model binary data as in Bayesian logistic regression, binary Gaussian Process Classification, and binary factor analysis. See our ICML-2011 paper for details.

Download: piecewiseBounds.zip

How to use the code: This piece of code computes an upper bound to the expectation of log(1+exp(x))) with respect to Gaussian with mean m and variance v.

   > bound = getBound(’linear’,20); % get linear bound with 20 pieces
   > m = [1 0 -1]’; v = [ 1 2 1]’; % specify mean and variance
   > [f,gm,gv] = funObj_pw(m,v,bound); % compute upper bound and gradient wrt m and v

f is 3x1 vector containing upper bounds to the expectation with respect to Gaussian with mean m and variance v, and [gm,gv] are the corresponding gradients.

Description of files:

  • funObj_pw.m computes the upper bound and gradients.
  • objgradpart_vec.m computes truncated Gaussian moments as described in the appendix.
  • getPiecewiseBound.m, getPieceWiseLinear.m and battlse.m are used to compute piecewise bounds.

System requirements and dependencies: The code works fine on MATLAB 7.4 (2007a) and higher versions. Function to compute linear piecewise bounds is written by Hsiung, Kim and Boyd.