Skip to content
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

report initialization as first draw #547

Open
bob-carpenter opened this issue Apr 28, 2017 · 4 comments
Open

report initialization as first draw #547

bob-carpenter opened this issue Apr 28, 2017 · 4 comments
Assignees
Milestone

Comments

@bob-carpenter
Copy link
Contributor

bob-carpenter commented Apr 28, 2017

Summary:

The first draw in the output summary if warmup is saved should be the initialization.

Description:

It currently doesn't.

Reproducible Steps:

Program:

parameters {
  real y;
}
model {
  y ~ normal(0, 1);
}

Current Output:

Output of

./norm sample save_warmup=1 init=0

is

# stan_version_major = 2
# stan_version_minor = 15
# stan_version_patch = 0
# model = norm_model
# method = sample (Default)
#   sample
#     num_samples = 1000 (Default)
#     num_warmup = 1000 (Default)
#     save_warmup = 1
#     thin = 1 (Default)
#     adapt
#       engaged = 1 (Default)
#       gamma = 0.050000000000000003 (Default)
#       delta = 0.80000000000000004 (Default)
#       kappa = 0.75 (Default)
#       t0 = 10 (Default)
#       init_buffer = 75 (Default)
#       term_buffer = 50 (Default)
#       window = 25 (Default)
#     algorithm = hmc (Default)
#       hmc
#         engine = nuts (Default)
#           nuts
#             max_depth = 10 (Default)
#         metric = diag_e (Default)
#         stepsize = 1 (Default)
#         stepsize_jitter = 0 (Default)
# id = 0 (Default)
# data
#   file =  (Default)
# init = 0
# random
#   seed = 3169738892
# output
#   file = output.csv (Default)
#   diagnostic_file =  (Default)
#   refresh = 100 (Default)
lp__,accept_stat__,stepsize__,treedepth__,n_leapfrog__,divergent__,energy__,y
-0.552707,0.57539,2,1,1,0,0.690883,-1.05139

Expected Output:

First value of y should be 0.

Additional Information:

Provide any additional information here.

Current Version:

v2.15.0

@syclik
Copy link
Member

syclik commented Apr 28, 2017

Thanks for tagging this as v3.0.0. I don't think we can change existing behavior because it'll be a off-by-one nightmare everywhere, but if we do split to multiple files, this will be easy.

I just tagged @betanalpha just to see if he has any thoughts.

@goedman
Copy link
Member

goedman commented May 2, 2017

Thanks Bob and Daniel. I'll create a similar test case for Stan.jl to track this issue and the other outstanding 3.0.0 issue (save-warmups and thinning, #510 ).

Adding this initial value to the saved warmups samples I guess is just for educational purposes, as Chris was using it?

@mitzimorris
Copy link
Member

mitzimorris commented Sep 1, 2023

there's an unused argument to all service call methods: init_writer which seems to be intended to capture the initial parameters on the unconstrained scale.

used by CmdStan here:

stan::callbacks::writer init_writer; // always no-op writer

ignored by services methods here: https://github.com/stan-dev/stan/blob/6d35a762bf56c72fef574302e5af4b9c70703625/src/stan/services/util/initialize.hpp#L209
(but this is after the unconstraining xform - we'd want to output the first draw on the constrained scale).

at this point, we've got enough hooks on the model class that we could hook this up to its own file and output this info.

@jucor
Copy link

jucor commented Dec 7, 2023

This would very much help diagnostics, thank you!
(See https://discourse.mc-stan.org/t/does-the-init-argument-work-with-cmdstanr/17255/11 for example, or the hour I just spent trying to understand why I didn't find my init values in the warmup 😅)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants