Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions src/stan/services/util/initialize.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,28 +121,26 @@ std::vector<double> initialize(Model& model, const stan::io::var_context& init,

msg.str("");
double log_prob(0);
std::vector<double> gradient;
try {
// we evaluate the log_prob function with propto=false
// because we're evaluating with `double` as the type of
// the parameters.
log_prob = model.template log_prob<false, Jacobian>(unconstrained,
disc_vector, &msg);
log_prob = stan::model::log_prob_grad<true, Jacobian>(
model, unconstrained, disc_vector, gradient, &msg);
if (msg.str().length() > 0)
logger.info(msg);
} catch (std::domain_error& e) {
if (msg.str().length() > 0)
logger.info(msg);
logger.info("Rejecting initial value:");
logger.info(
" Error evaluating the log probability"
" Error evaluating the log probability with gradients"
" at the initial value.");
logger.info(e.what());
continue;
} catch (std::exception& e) {
if (msg.str().length() > 0)
logger.info(msg);
logger.info(
"Unrecoverable error evaluating the log probability"
"Unrecoverable error evaluating the log probability with gradients"
" at the initial value.");
logger.info(e.what());
throw;
Expand All @@ -158,7 +156,6 @@ std::vector<double> initialize(Model& model, const stan::io::var_context& init,
continue;
}
std::stringstream log_prob_msg;
std::vector<double> gradient;
auto start = std::chrono::steady_clock::now();
try {
// we evaluate this with propto=true since we're
Expand All @@ -168,6 +165,8 @@ std::vector<double> initialize(Model& model, const stan::io::var_context& init,
} catch (const std::exception& e) {
if (log_prob_msg.str().length() > 0)
logger.info(log_prob_msg);
logger.info(
" Failed to evaluate log_prob with gradients for performance test");
logger.info(e.what());
throw;
}
Expand Down