Skip to content
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

poutine.reparam(model,-) breaks AutoGuide initialization #2832

Closed
fritzo opened this issue May 4, 2021 · 2 comments
Closed

poutine.reparam(model,-) breaks AutoGuide initialization #2832

fritzo opened this issue May 4, 2021 · 2 comments

Comments

@fritzo
Copy link
Member

fritzo commented May 4, 2021

poutine.reparam(model, -) currently replaces targeted model sites with deterministic sites and introduces auxiliary latent variables upstream. While this site swapping is mostly compatible with AutoGuides, it does break autoguide initialization, since init_loc_fn(-) initializes based on the original site name.

Despite this breakage, Reparam objects generally know how to transform between downstream original latents and upstream auxiliary latents. Thus there is an opportunity to refactor AutoGuide initialization and/or Reparam.__call__() so that autoguides are more agnostic to reparameterization.

As proof of concept, consider adding inside each reparametrizer a new non-traced site that is used only for initialization:

  class MyReparam(Reparam):
      def __call__(self, name, fn, value):
            ...
+           if initializing:  # read from some global state?
+               value = pyro.sample(name, fn, infer={"_do_not_trace": True})
+               value_t = my_transform(value)
+               with poutine.condition(data={name + "_transformed": transformed_value}):
+                   return self(name, fn, value)
          ...            
@fehiepsi
Copy link
Member

fehiepsi commented May 4, 2021

cc @martinjankowiak - who also concerned about this

@fritzo
Copy link
Member Author

fritzo commented Aug 30, 2021

I believe this was fixed by #2876

@fritzo fritzo closed this as completed Aug 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants