You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
TransformVariables.jl's transform takes a transformation and a floating-point vector x to a structured value (e.g. a named tuple) y. But transform is just a wrapper around transform_with, which does most of the work. I really like the way this is structured, and I think something like it can be useful for us.
This can take six unbounded reals and map them to a 2x3 array with each component in the unit interval. But often we have a transform that's made up of other transforms; this is where transform_with comes in.
Say I started with a vector
julia> x =rand(Float16, 10)
10-element Vector{Float16}:0.40920.54350.2480.73970.99460.85350.16060.7460.42920.784
A LogJacFlag indicating whether we want to compute the logjac,
The transform,
The input vector, and
The starting index
And as a result we get
The desired 2x3 array,
The logjac, and
The next index
The index state tells us the next index to use, a lot like you'd do with Julia's iterator protocol.
I think we can have something like this, except that the "transform" can be more general. Maybe it maps from $\mathbb{R}^n$, or maybe from a hypercube. It might be a "transform" in the TransformVariables sense, or it could be a transport.
Another thing... In Tilde, a transform will have to call runmodel. In a naive implementation, we'd have to call that again to get the log-density. Instead, we should set this up so we can get the log-density at the same time as we're doing the transform. This can be much more efficient. Note that we don't need this for transports, because in that case we can get the log-density more directly from x, and y is only needed for computing the likelihood. In fact, we may want to allow only computing those variables that will be needed for the likelihood, but wiring things up that way could be tricky, so let's come back to that.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
TransformVariables.jl's
transform
takes a transformation and a floating-point vectorx
to a structured value (e.g. a named tuple)y
. Buttransform
is just a wrapper aroundtransform_with
, which does most of the work. I really like the way this is structured, and I think something like it can be useful for us.Say our transform is
This can take six unbounded reals and map them to a 2x3 array with each component in the unit interval. But often we have a transform that's made up of other transforms; this is where
transform_with
comes in.Say I started with a vector
(16 bit so they take up less screen space)
Then we can call
The inputs are
LogJacFlag
indicating whether we want to compute the logjac,And as a result we get
The index state tells us the next index to use, a lot like you'd do with Julia's iterator protocol.
I think we can have something like this, except that the "transform" can be more general. Maybe it maps from$\mathbb{R}^n$ , or maybe from a hypercube. It might be a "transform" in the TransformVariables sense, or it could be a transport.
Another thing... In Tilde, a transform will have to call
runmodel
. In a naive implementation, we'd have to call that again to get the log-density. Instead, we should set this up so we can get the log-density at the same time as we're doing the transform. This can be much more efficient. Note that we don't need this for transports, because in that case we can get the log-density more directly fromx
, andy
is only needed for computing the likelihood. In fact, we may want to allow only computing those variables that will be needed for the likelihood, but wiring things up that way could be tricky, so let's come back to that.Beta Was this translation helpful? Give feedback.
All reactions