lp in Stan's variational interface

151 views
Skip to first unread message

Jiqiang Guo

unread,
Jul 10, 2015, 11:34:23 AM7/10/15
to stan...@googlegroups.com
Two questions:

lp in the output file is always zero?  Is this lp the same as lp__? 

Please see output below.

Jiqiang 


$ ./bernoulli variational data file=bernoulli.data.R output file=v.csv
 method = variational
   variational
     algorithm = meanfield (Default)
       meanfield
     iter = 10000 (Default)
     grad_samples = 1 (Default)
     elbo_samples = 100 (Default)
     eta_adagrad = 0.10000000000000001 (Default)
     tol_rel_obj = 0.01 (Default)
     eval_elbo = 100 (Default)
     output_samples = 1000 (Default)
 id = 0 (Default)
 data
   file = bernoulli.data.R
 init = 2 (Default)
 random
   seed = 2143042049
 output
   file = v.csv
   diagnostic_file =  (Default)
   refresh = 100 (Default)


This is Automatic Differentiation Variational Inference.

(EXPERIMENTAL ALGORITHM: expect frequent updates to the procedure.)

Gradient evaluation took 0 seconds
1000 iterations under these settings should take 0 seconds.
Adjust your expectations accordingly!

  iter       ELBO   delta_ELBO_mean   delta_ELBO_med   notes
     0     -2e+01             1.000            1.000
   100       -6.3             1.197            1.393
   200       -6.6             0.812            1.000   MAY BE DIVERGING... INSPECT ELBO
   300       -6.2             0.626            1.000   MAY BE DIVERGING... INSPECT ELBO
   400       -6.3             0.504            0.067   MAY BE DIVERGING... INSPECT ELBO
   500       -6.3             0.421            0.067
   600       -6.2             0.363            0.042
   700       -6.3             0.320            0.042
   800       -6.3             0.285            0.020
   900       -6.3             0.257            0.020
  1000       -6.1             0.160            0.020
  1100       -6.3             0.023            0.020
  1200       -6.2             0.020            0.017
  1300       -6.2             0.014            0.015
  1400       -6.5             0.016            0.015
  1500       -6.2             0.020            0.020
  1600       -6.2             0.019            0.020
  1700       -6.2             0.017            0.013
  1800       -6.2             0.018            0.013
  1900       -6.2             0.019            0.013
  2000       -6.3             0.017            0.012
  2100       -6.4             0.016            0.012
  2200       -6.2             0.018            0.012
  2300       -6.3             0.018            0.012
  2400       -6.2             0.015            0.012
  2500       -6.3             0.010            0.010   MEDIAN ELBO CONVERGED

$ R -q -e 'a<-read.csv("v.csv",header=T,comment.char="#"); str(a)'
> a<-read.csv("v.csv",header=T,comment.char="#"); str(a)
'data.frame':   1001 obs. of  2 variables:
 $ lp   : int  0 0 0 0 0 0 0 0 0 0 ...
 $ theta: num  0.214 0.222 0.109 0.264 0.347 ...
>

Dustin Tran

unread,
Jul 10, 2015, 12:19:00 PM7/10/15
to stan...@googlegroups.com
Yup. The log probability (lp) is not well-defined there for variational inference. Recall the solved parameters are parameters of the variational family, not the posterior, and the first line of the table simply takes the mean of the variational distribution, c.f., reference manual. Thus as a hack because Stan requires at least that column, we left it there while writing 0.
--
You received this message because you are subscribed to the Google Groups "stan development mailing list" group.
To unsubscribe from this group and stop receiving emails from it, send an email to stan-dev+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jiqiang Guo

unread,
Jul 10, 2015, 3:06:15 PM7/10/15
to stan...@googlegroups.com
Got it.  Thanks.

I meant to suggest adding two underscores to lp.


Jiqiang 

Bob Carpenter

unread,
Jul 10, 2015, 3:08:15 PM7/10/15
to stan...@googlegroups.com

Let's look into refactoring that into less of a hack. We shouldn't be requiring
lp__ in anything downstream. Feel free to bring these things up during
design, and we can look into redoing them as we go so we don't wind up with
a hack release that we want to fix later by getting rid of lp__.

- Bob

Bob Carpenter

unread,
Jul 10, 2015, 3:09:05 PM7/10/15
to stan...@googlegroups.com
Dustin --- would you mind opening an issue (CmdStan or Stan)
where this refactor should go? What exactly assumes that lp__ is defined?

- Bob

Michael Betancourt

unread,
Jul 10, 2015, 4:22:27 PM7/10/15
to stan...@googlegroups.com
The only thing that requires lp are the mcmc_writer
and the sample class, both of which shouldn’t be
used by anything other than MCMC algorithms...

Dustin Tran

unread,
Jul 10, 2015, 4:45:21 PM7/10/15
to stan...@googlegroups.com
Added it: https://github.com/stan-dev/stan/issues/1538
It’s the write_iteration function(s).

Dustin

Ben Goodrich

unread,
Jul 10, 2015, 5:08:30 PM7/10/15
to stan...@googlegroups.com, ca...@alias-i.com
On Friday, July 10, 2015 at 3:08:15 PM UTC-4, Bob Carpenter wrote:
Let's look into refactoring that into less of a hack.  We shouldn't be requiring
lp__ in anything downstream.   Feel free to bring these things up during
design, and we can look into redoing them as we go so we don't wind up with
a hack release that we want to fix later by getting rid of lp__.

Is there a lesser hack that would allow us to avoid this hack and get 2.7.0 out?

Ben

Ben Goodrich

unread,
Jul 12, 2015, 3:58:53 AM7/12/15
to stan...@googlegroups.com, dustinv...@gmail.com
On Friday, July 10, 2015 at 12:19:00 PM UTC-4, Dustin Tran wrote:
Yup. The log probability (lp) is not well-defined there for variational inference. Recall the solved parameters are parameters of the variational family, not the posterior, and the first line of the table simply takes the mean of the variational distribution, c.f., reference manual. Thus as a hack because Stan requires at least that column, we left it there while writing 0.

Yes, but after it has optimized the ELBO and then draws from a multivariate normal in the unconstrained space and transforms those draws into the constrained space, can't it then evaluate the log-posterior? This seems like it would be no more or less useful than the lp__ that comes out of our MCMC algorithms. If we did that and changed the "lp" column of the csv file to "lp__", then we can worry about generalizing the csv writer until after 2.7.0.

Ben


Dustin Tran

unread,
Jul 12, 2015, 11:59:23 AM7/12/15
to stan...@googlegroups.com
Sure that sounds like the most ready option. I have the changes done locally but am stuck in a train and don't have internet on my laptop quite yet. Will push/submit the two pull requests (for both cmdstan and stan) once I do.

Dustin
Reply all
Reply to author
Forward
0 new messages