Closed chrism0dwk closed 1 year ago
Hi Chris --
The preconditioning_utils
are not the most ergonomic, nor the most public, but this code almost works.
If you use batch_shape=tf.TensorShape([])
, it "works on my colab". The batch_shape
here can be set to the tf.shape
of the log_prob of your model at the initial point(s).
Note that in general the MCMC stack expects lists of state parts, so momentum
will not be a structure-aware object:
>>> momentum.sample()
[<tf.Tensor: shape=(), dtype=float32, numpy=-2.8567312>,
<tf.Tensor: shape=(3,), dtype=float32, numpy=array([ 0.55520535, -1.6700784 , 1.2413677 ], dtype=float32)>]
That's great, thanks again and sorry for the disgraceful typo above (now edited!). I think I've had a couple of times today where TF2.10.0 has explicitly demanded a TensorShape when previously a regular Tensor (or even a Python list) would do, so maybe the semantics are tightening up.
Chris
Hi Guys,
I could use a little help getting a
DiagonalMassMatrixAdaptation
/DualAveragingStepSizeAdaptation
/PreconditionedHamiltonianMonteCarlo
onion going. I begin with aStructTuple
of state parts, which came out of aJointDistributionCoroutine
model, and encounter an error in constructing the initial momentum distribution.For example:
Then to construct the momentum distribution for the
PreconditionedHamiltonianMonteCarlo
I doallowing the
running_variance_parts
to be set by the function call. However, I get an error:Have I stepped outside the design envelope, I wonder, or is there a bug?
Cheers,
Chris