-
-
Notifications
You must be signed in to change notification settings - Fork 368
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Log density with proportionality in ADVI drops more than constant #2518
Comments
Can you provide a minimal example? An easy way to do it is to just put it
on a branch. (The breadcrumbs you left aren't enough.) Or just isolate it
in a test.
Something looks off. Can you print the cont_params_ and the values for
log_p_exact and log_p_prop? That would help a bit.
…On Wed, Apr 25, 2018 at 10:04 PM, Yuling Yao ***@***.***> wrote:
Summary:
Log density with proportionality in ADVI drops more than constant
Description:
According to stan C++ guidance (https://github.com/stan-dev/
stan/wiki/Model-Concept), the log probability of a stan model, with or
without proportionality, can be calculated from
template <bool propto, bool jacobian_adjust_transforms, typename T>
T
log_prob(std::vector<T>& params_r,
std::vector<int>& params_i,
std::ostream* msgs = 0)
const;
But I find the difference between the exact and proportional log density
in Stan ADVI code is not a constant.
Reproducible Steps:
In order to calculate both the exact log density and proportional log
density in the unconstrained space, and to print their difference, add
these lines before
https://github.com/stan-dev/stan/blob/12f031565df6265356bdc4c6b191d8
df619151f5/src/stan/variational/advi.hpp#L540
double log_p_exact=0;
double log_p_prop=0;
log_p_exact = model_.template log_prob<false, true>(cont_params_);
log_p_prop = model_.template log_prob<true, true>(cont_params_);
std::stringstream ss;
ss << "constant dropped="<<log_p_exact-log_p_prop<<"======";
std::cout<<ss.str();
Then we can make cmdstan and run the bernoulli example:
examples/bernoulli/bernoulli variational algorithm=meanfield iter=1000 output_samples=30 data file=examples/bernoulli/bernoulli.data.R
Current Output:
We should expect the output being a constant for all posterior draws,
which stands for the log constant term in densities. But it is not. For
instance here is the first 6 lines of the output:
constant dropped==-5.24628
constant dropped==-5.20678
constant dropped==-5.78415
constant dropped==-5.37678
constant dropped==-5.02283
constant dropped==-5.59698
I check that the exact log density ( model_.template log_prob<false, true>
) does return the log density plus jacobian.
Current Version:
v2.17.1
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#2518>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAZ_F2pz4yqLIVWm9a_1egPgVO-QxrYOks5tsSsbgaJpZM4TkaHA>
.
|
The problem seems to be that there are calls from within ADVI that use |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Summary:
Log density with proportionality in ADVI drops more than constant
Description:
According to stan C++ guidance (https://github.com/stan-dev/stan/wiki/Model-Concept), the log probability of a stan model, with or without proportionality, can be calculated from
But I find the difference between the exact and proportional log density in Stan ADVI code is not a constant.
Reproducible Steps:
In order to calculate both the exact log density and proportional log density in the unconstrained space, and to print their difference, add these lines before
stan/src/stan/variational/advi.hpp
Line 540 in 12f0315
Then we can make cmdstan and run the bernoulli example:
Current Output:
We should expect the output being a constant for all posterior draws, which stands for the log constant term in densities. But it is not. For instance here is the first 6 lines of the output:
I check that the exact log density ( model_.template log_prob<false, true> ) does return the log density plus jacobian.
Current Version:
v2.17.1
The text was updated successfully, but these errors were encountered: