Closed aplavin closed 1 year ago
I consider calculating the log determinant of the Jacobian major functionality, and I am not sure how you would implement that with optics. See transform_and_logjac
.
Also, a lot of transformations are nonlinear mappings.
Are you sure you read the manual?
Also, a lot of transformations are nonlinear mappings.
See log
s in my example, nonlinear functions work just fine.
calculating the log determinant of the Jacobian
Thanks for pointing this out! Not sure if I totally understand what exactly is meant by Jacobian here. It's commonly defined for vector-to-vector functions, but what's a Jacobian of NamedTuple function as((μ = asℝ, σ = asℝ₊, τ = asℝ₊, θs = as(Array, 8)))
?
Optics can easily be differentiated, I regularly compute gradients with them. But don't understand what you mean by Jacobian.
Yes, that's the definition of log-Jacobian for functions R^n -> R^n (vector -> vector). But what's a Jacobian of a vector -> namedtuple function?
The Jacobian of the result flattened to a vector. (Edit: for non-bijective transforms, a subset, eg the upper triangle of correlation matrices).
I see... This very specific functionality is not available out of the box in Accessors. One can use regular autodiff there to find gradients/jacobians/..., but need to specify both input(s) and output(s) of the differentiated function instead of them being implicit.
Sorry for bothering with the suggestion then. I made this issue just because earlier at some point I used TransformVariables
for transform
/inverse
, and now optics replaced that functionality for me.
No worries, suggestions are always welcome. Yes, this functionality is very specific to Bayesian estimation / MCMC. I will close the issue for now as I think it is resolved, but if you comment I will reopen it.
Looks like all major functionality of
TransformVariables
is available as optics/lenses, as defined inAccessors
. Optics are very general and composable, so maybe it's worth looking into "replacing"TransformVariables
usage with optics. If some useful features aren't covered by optics yet, this most likely can be improved.Simple example along the lines of
TransformVariables
docs: