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
Improvements to Importance Sampling and InferenceData shape
- Handle different importance sampling methods for reshaping and adjusting log densities.
- Modified to return InferenceData with chain dim of size num_paths when
Zhang, L., Carpenter, B., Gelman, A., & Vehtari, A. (2022). Pathfinder: Parallel quasi-Newton variational inference. Journal of Machine Learning Research, 23(306), 1-49.
80
79
"""
81
80
82
-
ifmethod=="psis":
83
-
replace=False
84
-
logiw, pareto_k=PSIS()(logiw)
85
-
elifmethod=="psir":
86
-
replace=True
87
-
logiw, pareto_k=PSIS()(logiw)
88
-
elifmethod=="identity":
89
-
replace=False
90
-
logiw=logiw
91
-
pareto_k=None
92
-
elifmethod=="none":
81
+
num_paths, num_pdraws, N=samples.shape
82
+
83
+
ifmethod=="none":
93
84
logger.warning(
94
85
"importance sampling is disabled. The samples are returned as is which may include samples from failed paths with non-finite logP or logQ values. It is recommended to use importance_sampling='psis' for better stability."
value used to filter out large changes in the direction of the update gradient at each iteration l in L. Iteration l is only accepted if delta_theta[l] * delta_grad[l] > epsilon * L2_norm(delta_grad[l]) for each l in L. (default is 1e-8).
883
884
importance_sampling : str, optional
884
-
importance sampling method to use. Options are "psis" (default), "psir", "identity", "none. Pareto Smoothed Importance Sampling (psis) is recommended in many cases for more stable results than Pareto Smoothed Importance Resampling (psir). identity applies the log importance weights directly without resampling. none applies no importance sampling weights and returns the samples as is of size num_draws_per_path * num_paths.
885
+
importance sampling method to use which applies sampling based on the log importance weights equal to logP - logQ. Options are "psis" (default), "psir", "identity", "none". Pareto Smoothed Importance Sampling (psis) is recommended in many cases for more stable results than Pareto Smoothed Importance Resampling (psir). identity applies the log importance weights directly without resampling. none applies no importance sampling weights and returns the samples as is of size (num_paths, num_draws_per_path, N) where N is the number of model parameters, otherwise sample size is (num_draws, N).
885
886
progressbar : bool, optional
886
887
Whether to display a progress bar (default is False). Setting this to True will likely increase the computation time.
0 commit comments