Classes | Functions
stan::services::diagnose Namespace Reference


struct  epsilon
struct  error


template<class Model >
int diagnose (Model &model, stan::io::var_context &init, unsigned int random_seed, unsigned int chain, double init_radius, double epsilon, double error, callbacks::interrupt &interrupt, callbacks::logger &logger, callbacks::writer &init_writer, callbacks::writer &parameter_writer)

Function Documentation

template<class Model >
int stan::services::diagnose::diagnose ( Model model,
stan::io::var_context init,
unsigned int  random_seed,
unsigned int  chain,
double  init_radius,
double  epsilon,
double  error,
callbacks::interrupt interrupt,
callbacks::logger logger,
callbacks::writer init_writer,
callbacks::writer parameter_writer 

Checks the gradients of the model computed using reverse mode autodiff against finite differences.

This will test the first order gradients using reverse mode at the value specified in cont_params. This method only outputs to the logger.

Template Parameters
ModelA model implementation
[in]modelInput model to test (with data already instantiated)
[in]initvar context for initialization
[in]random_seedrandom seed for the random number generator
[in]chainchain id to advance the pseudo random number generator
[in]init_radiusradius to initialize
[in]epsilonepsilon to use for finite differences
[in]erroramount of absolute error to allow
[in,out]interruptinterrupt callback
[in,out]loggerLogger for messages
[in,out]init_writerWriter callback for unconstrained inits
[in,out]parameter_writerWriter callback for file output
the number of parameters that are not within epsilon of the finite difference calculation

Definition at line 43 of file diagnose.hpp.

References stan::services::util::create_rng(), epsilon, stan::callbacks::logger::info(), and stan::services::util::initialize().

Referenced by TEST_F(), and ana::StanFitter::TestGradients().

49  {
50  boost::ecuyer1988 rng = util::create_rng(random_seed, chain);
52  std::vector<int> disc_vector;
53  std::vector<double> cont_vector
54  = util::initialize(model, init, rng, init_radius,
55  false,
56  logger, init_writer);
60  int num_failed
61  = stan::model::test_gradients<true, true>(model, cont_vector,
62  disc_vector, epsilon, error,
63  interrupt, logger,
64  parameter_writer);
66  return num_failed;
67  }
Check that an output directory exists.
std::vector< double > initialize(Model &model, stan::io::var_context &init, RNG &rng, double init_radius, bool print_timing, stan::callbacks::logger &logger, stan::callbacks::writer &init_writer)
Definition: initialize.hpp:68
double epsilon
const XML_Char XML_Content * model
Definition: expat.h:151
boost::ecuyer1988 create_rng(unsigned int seed, unsigned int chain)
Definition: create_rng.hpp:25