Skip to content

Fix the behaviour of realizations objects that were just reference to model parameters during first iteration

Nemo Fournier requested to merge fix_realizations_first_iteration into dev

What does the code in the MR do ?

Fix #109, by making sure that the tensor attribute of PopulationRealization objects initialized from model parameters are not just reference to the model parameter tensor. This caused the first iteration of the model to modify the value of the model.parameters tensors during sampling (and effectively made computation of regularization wrong — they should be computed based on the "frozen" version of model.parameters of previous iterations. This behaviour was only existent in the first iteration because the compute_model_sufficient_statistics method of MultivariateModel (and probably in other models as well, I have not checked) performs the following on the ambient realizations object, in which some correct "cloning" is performed.

# unlink all sufficient statistics from updates in realizations!
realizations = realizations.clone()

FYI this behaviour is already fixed in v2, and was the cause of some discrepancies observed in the first iteration.

It might break a bunch of tests though, since computation might diverge at step 1 between current dev and this fix.

Merge request reports