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

Implement StickBreakingTransform.log_abs_det_jacobian() #112

Closed
fritzo opened this issue Jan 29, 2018 · 5 comments
Closed

Implement StickBreakingTransform.log_abs_det_jacobian() #112

fritzo opened this issue Jan 29, 2018 · 5 comments

Comments

@fritzo
Copy link
Collaborator

fritzo commented Jan 29, 2018

This is needed to do HMC over simplex-constrained random variables, e.g. for Dirichlet random variables.

It would really help to have tests #110 complete to test correctness of this tricky bit of math.

@fritzo fritzo added this to Planned in Distributions Kanban Jan 29, 2018
@fritzo fritzo moved this from Planned to In Progress in Distributions Kanban Mar 17, 2018
@fritzo fritzo moved this from In Progress to In Review in Distributions Kanban Mar 17, 2018
@fritzo
Copy link
Collaborator Author

fritzo commented Mar 21, 2018

This is being implemented in pytorch#5547

@fritzo
Copy link
Collaborator Author

fritzo commented Mar 28, 2018

This was implemented in pytorch#5547 but may be buggy and does not work. We should add tests and fix the bugs.

@alshedivat Have you used StickBreakingTransform.log_abs_det_jacobian() at all? Do you have any ideas for tests?

EDIT sorry, I'm not sure where my bugs are, and they may not be in this function. But I would feel more confident if we had some tests for this function 🙂

@fritzo fritzo added the bug label Mar 28, 2018
@alshedivat
Copy link

@fritzo, my implementation is based on Stan's reference manual, v2.17.0 (Section 35.6, pp. 408-410) and uses the inverted stick-breaking construction. I also used an offset as suggested in the manual to make sure all zeros vector maps to the center of the simplex. I have used LogisticNormal distribution which is based on this transform.

Note: The original implementation of the StickBreakingTransform (before pytorch#5547) was slightly different. Could the bugs be due to assuming a particular form of the transform? (E.g., assuming no offset?). Could you elaborate more on what the bug is?

Edward uses the same construction in their to_simplex util function. We can borrow some tests from there, but I'm not sure if they have log_abs_det_jacobian implemented and tested.

@dustinvtran, do you happen to know a good way to test StickBreakingTransform? How is it done in Edward or Stan? (I can't find the relevant code.)

@fritzo
Copy link
Collaborator Author

fritzo commented Mar 28, 2018

@alshedivat Thanks for explaining. @ssnl pointed out that we could use torch.slogdet, but we would need to deal with the Jacobian not being square.

@dustinvtran
Copy link

Thanks for pinging me. We haven't implemented and tested a log_abs_det_jacobian for the stick breaking transform. I wholeheartedly agree with this direction though :) Stick breaking transforms are great.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants