-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ENH: Option to adjust the uniform distribution bounds for jitter/initialisation #7555
Comments
If you pass the default strategy == ”prior" you'll get much more variation. Does that suffice? Otherwise would a single jitter_scale argument suffice? Do you need to be able to specify both bounds? And will you need to vary this per variable? |
Depending on the scenario, setting the default strategy == "prior" gives too much variation. Having jitter ~ U(-2, -2) may be too much variation, and for other problems, jitter ~ U(-20, 20) would be better. The option to set the jitter would be useful. What's demonstrated in the Pathfinder paper is for jitter to have a single bound and its the same bound for all variables. For now single bound and for all variables should be okay. I have implemented a workaround in this commit pymc-devs/pymc-experimental#386 which has the initialisation needed for pathfinder: def make_initial_pathfinder_point(
model,
jitter: float = 2.0,
random_seed: RandomSeed | None = None,
) -> DictToArrayBijection:
"""
create jittered initial point for pathfinder
Parameters
----------
model : Model
pymc model
jitter : float
initial values in the unconstrained space are jittered by the uniform distribution, U(-jitter, jitter). Set jitter to 0 for no jitter.
random_seed : RandomSeed | None
random seed for reproducibility
Returns
-------
DictToArrayBijection
bijection containing jittered initial point
"""
ipfn = make_initial_point_fn(
model=model,
)
ip = Point(ipfn(random_seed), model=model)
ip_map = DictToArrayBijection.map(ip)
rng = np.random.default_rng(random_seed)
jitter_value = rng.uniform(-jitter, jitter, size=ip_map.data.shape)
ip_map = ip_map._replace(data=ip_map.data + jitter_value)
return ip_map Happy for this request to now be closed or remain open if the jitter~U(-n, n) option should be available in the pymc library as well. |
Single jitter for all variables sounds fine, feel free to open a PR. Perhaps call it |
Before
After
Context for the issue:
To assist multi-path Pathfinder in exploring complicated posteriors (i.e., multimodal, flat or saddle point regions, or posteriors with several local modes that get stuck during optimisation), each single Pathfinder needs to be initialised over a broader region. This would require random initialisation points wider than Uniform(-1, 1). Attached is an image comparing wide and broad random initialisations from Figure 11 of the paper.
Allowing the uniform distribution bounds to be input parameters would allow users of the multi-path Pathfinder algorithm to adjust the initialisations to their scenario better.
I'm happy to work on this feature :) Any suggestions on how you'd like the changes to be made?
References:
Zhang, L., Carpenter, B., Gelman, A., & Vehtari, A. (2022). Pathfinder: Parallel quasi-Newton variational inference. Journal of Machine Learning Research, 23(306), 1–49.
The text was updated successfully, but these errors were encountered: