diff --git a/src/stan/services/util/initialize.hpp b/src/stan/services/util/initialize.hpp index fd180819b99..ef30446f7f1 100644 --- a/src/stan/services/util/initialize.hpp +++ b/src/stan/services/util/initialize.hpp @@ -121,12 +121,10 @@ std::vector initialize(Model& model, const stan::io::var_context& init, msg.str(""); double log_prob(0); + std::vector 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(unconstrained, - disc_vector, &msg); + log_prob = stan::model::log_prob_grad( + model, unconstrained, disc_vector, gradient, &msg); if (msg.str().length() > 0) logger.info(msg); } catch (std::domain_error& e) { @@ -134,7 +132,7 @@ std::vector initialize(Model& model, const stan::io::var_context& init, 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; @@ -142,7 +140,7 @@ std::vector initialize(Model& model, const stan::io::var_context& init, 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; @@ -158,7 +156,6 @@ std::vector initialize(Model& model, const stan::io::var_context& init, continue; } std::stringstream log_prob_msg; - std::vector gradient; auto start = std::chrono::steady_clock::now(); try { // we evaluate this with propto=true since we're @@ -168,6 +165,8 @@ std::vector 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; }