# Population Level Parameter Recovery Problem

**URL:** <https://discuss.bayesflow.org/t/population-level-parameter-recovery-problem/80>\
**Category:** General\
**Created:** [March 12, 2024, 10:02am UTC](https://discuss.bayesflow.org/t/population-level-parameter-recovery-problem/80 "2024-03-12T10:02:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![YufeiWu](https://avatars.discourse-cdn.com/v4/letter/y/4bbf92/32.png) [@YufeiWu](https://discuss.bayesflow.org/u/YufeiWu)\
**Post date:** [March 12, 2024, 10:02am UTC](https://discuss.bayesflow.org/t/population-level-parameter-recovery-problem/80/1 "2024-03-12T10:02:35Z")

</div>

Dear BayesFlow Team,

thanks for developing such an interesting tool, and I really enjoy working with it!

I was trying to train a network for a hierarchical two-choice drift diffusion model. It has 5 parameters in the individual level (two drift rates (b0 & b1), boundary separation (\alpha), response bias (\beta), and non-decision time (\tau)), and 10 parameters in the population level (the mean \mu and standard deviation \sigma of the five distributions where the individual parameters were drawn from).

The network settings are:

```auto
summary_net = bf.summary_networks.HierarchicalNetwork([
    #from the bottom level to the top level
    bf.networks.DeepSet(summary_dim=50), 
    bf.networks.DeepSet(summary_dim=200)
])

local_inference_net = bf.networks.InvertibleNetwork(
    num_params=5,
    coupling_settings={"dense_args": dict(kernel_regularizer=None), "dropout": False},
    name="local_ddm_inference"
)

hyper_inference_net = bf.networks.InvertibleNetwork(
    num_params=10,
    coupling_settings={"dense_args": dict(kernel_regularizer=None), "dropout": False},
    name="hyper_ddm_inference"
)

```

The training was fine, and the individual level parameters are nicely recovered after this much of training:

```auto
history = trainer.train_online(epochs=300, iterations_per_epoch=300, batch_size=10)

```

 ![individual level parameters recovery](https://canada1.discourse-cdn.com/flex007/uploads/bayesflow/original/1X/f903393cc57e008cd72fb34b36c2869c849606aa.png)

However, the population level parameter recovery is problematic for one parameter (in this case \sigma\_{b0}):

 ![population level parameters recovery](https://canada1.discourse-cdn.com/flex007/uploads/bayesflow/original/1X/0ddec6f122bdf7edaf89a2c9ba805ff679224dbe.png)  
From my experience of retraining the model several times, the problematic recovery only appears in the estimation of population-level standard deviation, but not on a certain standard deviation. For example, It can happen on \sigma\_{b0}, \sigma\_{b1} or \sigma\_\tau, and the plot here is only the output of one neural network model.

I am quite confused about this problem and I am seeking for help on this. Please let me know if anything is unclear here.

Thanks a lot!

Best,  
Yufei

---

<div class="post-metadata">

**Author:** ![YufeiWu](https://avatars.discourse-cdn.com/v4/letter/y/4bbf92/32.png) [@YufeiWu](https://discuss.bayesflow.org/u/YufeiWu)\
**Post date:** [March 12, 2024, 10:45am UTC](https://discuss.bayesflow.org/t/population-level-parameter-recovery-problem/80/2 "2024-03-12T10:45:50Z")

</div>

Some additional information is:

I trained these networks on GPU, and when I tried to investigate the latent space z with:

```auto
f = bf.diagnostics.plot_latent_space_2d(z_samples[1])

```

the z samples (of the population level I guess) has 32 dimensions.  
But from the tutorial I read that the dimensionality of the latent space is equal to the num\_params in the inference network. So that was a bit confusing as well.

Thanks!

---

<div class="post-metadata">

**Author:** ![KLDivergence](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.bayesflow.org/kldivergence/32/15_2.png) [@KLDivergence](https://discuss.bayesflow.org/u/KLDivergence)\
**Post date:** [March 13, 2024, 12:45pm UTC](https://discuss.bayesflow.org/t/population-level-parameter-recovery-problem/80/3 "2024-03-13T12:45:39Z")

</div>

I would start by dropping the `DeepSet` in favor of a `SetTransformer` summary network.
