Code Monkey home page Code Monkey logo

Comments (5)

syclik avatar syclik commented on July 29, 2024

I think action is on me to come up with possible exceptions to throw.

from stanc3.

syclik avatar syclik commented on July 29, 2024

I would suggest using std::system_error (introduced in C++11).
http://www.cplusplus.com/reference/system_error/system_error/

It takes a string and an error code. With pull request stan-dev/stan#2307, this should pass through and stop the samplers.

from stanc3.

WardBrian avatar WardBrian commented on July 29, 2024

This is a very small language change, but there are still a fair number of places in Stan where we are catching std::exception generically and not re-throwing it. One is in base_hamiltonian: https://github.com/stan-dev/stan/blob/develop/src/stan/mcmc/hmc/hamiltonians/base_hamiltonian.hpp#L65

So if your model initializes, no exception will cause it to stop. For example:

parameters {
  real mu;
}
model {
  mu ~ normal(0, 1);
  
  if (mu < 0) {
    array[1] int sigma;
    print(sigma[2]);
  }
}

If the indexing exception occurs during initialization, it will exit. But if initialization succeeds (e.g., keep re-running this program), you'll get a program which runs until sampling is complete, even though all these non-recoverable exceptions are thrown

from stanc3.

bob-carpenter avatar bob-carpenter commented on July 29, 2024

We could go in and fix the base Hamiltonian here. I don't like that it just swallows an exception without actually fixing it. At least it will cause a rejection.

from stanc3.

WardBrian avatar WardBrian commented on July 29, 2024

I've opened stan-dev/stan#3258 about the places I believe we would need changes in Stan.

from stanc3.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.