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

Adapt usage of log_abs_det_jacobian for torch>=1.8 #27

Merged
merged 1 commit into from Nov 9, 2021

Conversation

janfb
Copy link
Contributor

@janfb janfb commented Nov 8, 2021

The dependence on torch 1.8 makes sense because the current sbi version, which we want to use, depends on it.

With this change we get rid of the helper function get_log_abs_det_jacobian that was distinguishing between the behavior before and after torch 1.8 and was doing the summation explicitly.

Details:

  • with the dependence on torch>=1.8 the output of log_prob and log_abs_det_jacobian changes: when the input has several parameter dimensions the output will keep those dimensions and we would have to sum over them by hand to get the joint log_prob over parameter dimensions.
  • this can be prevented by "reinterpreting" them as batch dimensions.
  • for transforms this works via the IndependentTransform as a wrapper

See also #15

@janfb janfb changed the title depend on torch 1.8, adapt ladj usage and remove ladj helper. fix usage of log_abs_det_jacobian with torch=1.8 Nov 8, 2021
@janfb janfb changed the title fix usage of log_abs_det_jacobian with torch=1.8 fix usage of log_abs_det_jacobian with torch=1.8 Nov 8, 2021
@janfb
Copy link
Contributor Author

janfb commented Nov 8, 2021

we could add the fixed dependency on sbi in this branch as well, once the new sbi version is released.

@jan-matthis jan-matthis changed the title fix usage of log_abs_det_jacobian with torch=1.8 Adapt usage of log_abs_det_jacobian for torch>=1.8 Nov 9, 2021
@jan-matthis jan-matthis merged commit c454b54 into sbi-benchmark:main Nov 9, 2021
@jan-matthis
Copy link
Contributor

Great, cheers!

psteinb pushed a commit to psteinb/sbibm that referenced this pull request Nov 9, 2021
This was referenced Nov 15, 2021
@janfb janfb deleted the fix-ladj-usage branch February 16, 2023 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants