BAMresearch / bayem

Implementation and derivation of "Variational Bayesian inference for a nonlinear forward model." [Chappell et al. 2008] for arbitrary, user-defined model errors.
MIT License
2 stars 1 forks source link

Jacobian of individual models #6

Closed joergfunger closed 3 years ago

joergfunger commented 3 years ago

We are currently computing the Jacobian using finite differences, which is done by changing each global parameter, computing the global residual and then getting a complete full matrix. For problems, where we more than one experiment and latent parameters that are specific to one experiment (e.q. offsets, displacements as latent etc), this is a large overhead (since e.g. if experiment 1 does not depend on d2, then we know a priori that this derivative is zero). As a consequence, I think it could be advantageous to provide an ordered list of only the local latent variables (for a single experiment), provide this to compute the "local" Jacobian in (this order), and then assemble it together e.g. in a sparse fashion. An alternative to the sparse global sensitivity matrix would be returning each individual matrix, similar to the evaluate feature currently proposed and the user is then supposed to sum up the individual components.

joergfunger commented 3 years ago

On a side to this issue, Mathis just used our ModelError in a scipy.optimize routine, but using not a single experiment, but over a four hundred each with a couple of thousand data points and some 400 hundred variables (offset per experiment and joint Youngs modulus). I guess we need to implement the interface to compute Hessians of the model error rather soon. I guess the implementation is rather straightforward, we just have to agree on the interfaces. What do we return, a full Jacobian? Or (my preference) separate the contributions per model_error and then per parameter - this is how we compute that anyway. So we would access it as J['model_error1']['parameter1']

TTitscher commented 3 years ago

Merged in #15 There is still an issue discussed in #22