-
-
Notifications
You must be signed in to change notification settings - Fork 63
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
save_object() for variational fit loses return code #780
Comments
Thanks for reporting this. It would indeed be good to get the right return
codes after loading the saved model.
…On Tue, Jun 27, 2023 at 12:24 PM Kevin S. Van Horn ***@***.***> wrote:
*Describe the bug*
After running a variational estimation, saving the fit with save_object(),
and reading it back with readRDS(), return_codes() returns NA instead of
the return code from estimation.
*To Reproduce*
file <- file.path(cmdstanr::cmdstan_path(),
"examples/bernoulli/bernoulli.stan")
mod <- cmdstanr::cmdstan_model(file)
stan_data <- list(N = 10, y = c(0,1,0,0,0,0,0,0,0,1))
fit_vb <- mod$variational(data = stan_data, seed = 123)
fit_vb$return_codes() # returns 0 as expected
fit_vb$save_object('/Tmp/vbexample.rds')
fit_vb1 <- readRDS('/Tmp/vbexample.rds')
fit_vb1$return_codes() # returns NA
*Expected behavior*
The call fit_vb1$return_codes() should also return 0.
*Operating system*
Mac OS Ventura 13.4
*CmdStanR version number*
0.5.3.
*Additional context*
R version 4.2.2.
—
Reply to this email directly, view it on GitHub
<#780>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AB3PQQ4BLZVSTVOCKQOYLGTXNMQMJANCNFSM6AAAAAAZV7IWPU>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Following up on this, it's an issue not only for variational but also for sampling (and presumably all fitting methods). The problem is that for (id in private$proc_ids_) {
ret <- c(ret, self$get_proc(id)$get_exit_status())
} Presumably the solution to this is to store the return codes instead of trying to get the exit status every time the return codes are asked for. |
@ksvanhorn I have a PR open that fixes this: #798 Would you mind trying it out and making sure it resolves the issue you were having? |
Describe the bug
After running a variational estimation, saving the fit with save_object(), and reading it back with readRDS(), return_codes() returns NA instead of the return code from estimation.
To Reproduce
Expected behavior
The call
fit_vb1$return_codes()
should also return 0.Operating system
Mac OS Ventura 13.4
CmdStanR version number
0.5.3.
Additional context
R version 4.2.2.
The text was updated successfully, but these errors were encountered: