-
Notifications
You must be signed in to change notification settings - Fork 63
Adapter keeps track of the transform jacobians #419
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
base: dev
Are you sure you want to change the base?
Conversation
Thanks for the PR. Could you add tests for this behavior @Kucharssim? See e.g., |
Yes, on it! |
This was accidentally closed. We will investigate how to restore the branch and reopen PRs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for implementing this! I noted some minor concerns, mostly regarding clarity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the changes! I think we are mostly ready to merge this as-is. Can you address the open conversation above and the comments from Copilot? Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR enhances the adapter functionality by adding support for tracking the log determinant of the Jacobians across transforms. Key changes include:
- Introducing log_det_jac methods for several transforms (e.g. standardize, sqrt, scale, constrain, etc.).
- Modifying the adapter’s forward and inverse methods to optionally return the log determinant of the Jacobian.
- Adding comprehensive tests to verify the correct computation and exception handling for the Jacobian tracking.
Reviewed Changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
tests/test_adapters/test_adapters.py | Updated tests to cover additional keys and jacobian tracking tests. |
tests/test_adapters/conftest.py | Introduced new fixtures that test the log_det_jac functionality. |
bayesflow/approximators/continuous_approximator.py | Modified forward method to incorporate and apply the change‐of‐variables formula. |
bayesflow/adapters/transforms/* | Added or updated log_det_jac methods across multiple transform files. |
bayesflow/adapters/adapter.py | Updated forward and inverse methods to support the log_det_jac flag. |
Ok, I think I addressed everything now. If you are happy with this, feel free to merge |
fixes #245
I have not implemented it for
NumpyTransform
because I was not sure about implementation w.r.t. serialization. I tried to make sure that if we cannot keep track of the jacobians, we raise an error rather than returning an incorrect output.