TFP mcmc returns (num_samples, num_chains, ...), we swap
# the first and second axis below for each RV so the shape
# is what ArviZ expected.
k:np.swapaxes(v, 1, 0)
for k, v in mcmc_samples._asdict().items()},
sample_stats={
k:np.swapaxes(sampler_stats[k], 1, 0)
for k in ["target_log_prob", "diverging", "accept_ratio", "n_steps"]}
)
When I wrote this code and run on python I encounter this error:
I looked at the codes and I have not noticed any typos. Appreciate it if you help with this issue.
In your book page 76, Code 3.11 :
run_mcmc = tf.function( tfp.experimental.mcmc.windowed_adaptive_nuts, autograph=False, jit_compile=True) mcmc_samples, sampler_stats = run_mcmc( 1000, jd_penguin_mass_all_species, n_chains=4, num_adaptation_steps=1000, mass=body_mass_g)
inf_data_model_penguin_mass_all_species2 = az.from_dict( posterior={
TFP mcmc returns (num_samples, num_chains, ...), we swap
)
When I wrote this code and run on python I encounter this error:
I looked at the codes and I have not noticed any typos. Appreciate it if you help with this issue.
Thanks!