stan icon indicating copy to clipboard operation
stan copied to clipboard

Refactor write_iteration* functions

Open dustinvtran opened this issue 9 years ago • 10 comments

write_iteration_csv(...) currently requires specifying the log probability lp. This is unneeded for variational inference, and as a hack currently writes 0.0 there: https://github.com/stan-dev/stan/blob/develop/src/stan/variational/advi.hpp#L315-L317

From stan-dev mailing list:

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

Example of printing output.csv with cmdstan's print script:

# stan_version_major = 2
# stan_version_minor = 6
# stan_version_patch = 3
# model = bernoulli_model
# method = experimental
#   experimental
#     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 = 3959575278
# output
#   file = output.csv (Default)
#   diagnostic_file =  (Default)
#   refresh = 100 (Default)
lp,theta
0,0.221171
0,0.166458
0,0.297987
0,...
0,...
0,...

dustinvtran avatar Jul 10 '15 20:07 dustinvtran

Thanks for hunting this down. We should definitely generalize our functions. On Jul 10, 2015 4:43 PM, "Dustin Tran" [email protected] wrote:

write_iteration_csv(...) https://github.com/stan-dev/stan/blob/develop/src/stan/services/io/write_iteration_csv.hpp currently requires specifying the log probability lp. This is unneeded for variational inference, and as a hack currently writes 0.0 there: https://github.com/stan-dev/stan/blob/develop/src/stan/variational/advi.hpp#L315-L317

From stan-users mailing list https://groups.google.com/forum/#!topic/stan-dev/Bo5fWHI12iA:

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

— Reply to this email directly or view it on GitHub https://github.com/stan-dev/stan/issues/1538.

syclik avatar Jul 10 '15 20:07 syclik

Cough, cough — already done in the writer refactor — cough, cough

On Jul 10, 2015, at 10:56 PM, Daniel Lee [email protected] wrote:

Thanks for hunting this down. We should definitely generalize our functions. On Jul 10, 2015 4:43 PM, "Dustin Tran" [email protected] wrote:

write_iteration_csv(...) https://github.com/stan-dev/stan/blob/develop/src/stan/services/io/write_iteration_csv.hpp currently requires specifying the log probability lp. This is unneeded for variational inference, and as a hack currently writes 0.0 there: https://github.com/stan-dev/stan/blob/develop/src/stan/variational/advi.hpp#L315-L317

From stan-users mailing list https://groups.google.com/forum/#!topic/stan-dev/Bo5fWHI12iA:

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

— Reply to this email directly or view it on GitHub https://github.com/stan-dev/stan/issues/1538.

— Reply to this email directly or view it on GitHub.

betanalpha avatar Jul 10 '15 20:07 betanalpha

Are you sure we can't break that refactoring into a lot of smaller pull requests?

syclik avatar Jul 11 '15 15:07 syclik

Is this issue solved yet? I think so but I don't want to close it without confirmation.

dustinvtran avatar Feb 28 '16 23:02 dustinvtran

I don't think so... it's not updated on develop, right? (Normally, I'd check first, but hopefully it's easy for you to confirm.)

syclik avatar Feb 29 '16 02:02 syclik

Oh, you're right. I mistook my above issue with something else about streams. Yes we still have to do a hack by inputting 0 for the log prob's.

dustinvtran avatar Feb 29 '16 02:02 dustinvtran

is michael's refactor comment (betanalpha commented on Jul 10, 2015) relevant?

or do we need to make some further change to write_iteration?

akucukelbir avatar Mar 04 '16 13:03 akucukelbir

This seems to be already done - lp is not written by ADVI (by my reading of the codebase) could @betanalpha verify and close?

martinmodrak avatar Jun 04 '18 09:06 martinmodrak

Thanks, @martinmodrak --this kind of purposeful auditing of issues is really helpful.

bob-carpenter avatar Jun 05 '18 03:06 bob-carpenter

I think it's not done, as src/stan/variational/advi.hpp still contains these lines:

// Write lp__, log_p, and log_g.
values.insert(values.begin(), {0, log_p, log_g});

mcol avatar Dec 16 '19 15:12 mcol