Skip to content

Unconditional LazyTransform workaround - #1099

Merged
gmoss13 merged 5 commits into
mainfrom
1074-compatibility-fo-lazytransform-and-affinetransform-
Mar 24, 2024
Merged

gmoss13 merged 5 commits into
mainfrom
1074-compatibility-fo-lazytransform-and-affinetransform-

Conversation

@gmoss13

@gmoss13 gmoss13 commented Mar 22, 2024

Copy link
Copy Markdown
Contributor

What does this implement/fix? Explain your changes

Currently, the z-scoring layer for zuko transforms uses the Unconditional class from zuko, however this throws a pyright error when creating zuko flows, as Unconditional does not inherit from LazyTransform, which is expected to be the class of all transforms in a zuko Flow object. Here we create a temporary workaround, and will also start an issue in zuko for this.

Does this close any currently open issues?

Fixes #1074

Checklist

  • I have read and understood the contribution
    guidelines
  • I agree with re-licensing my contribution from AGPLv3 to Apache-2.0.
  • I have commented my code, particularly in hard-to-understand areas
  • I have added tests that prove my fix is effective or that my feature works
  • I have reported how long the new tests run and potentially marked them
    with pytest.mark.slow.
  • New and existing unit tests pass locally with my changes
  • I performed linting and formatting as described in the contribution
    guidelines
  • I rebased on main (or there are no conflicts with main)

@gmoss13
gmoss13 requested a review from Baschdl March 22, 2024 11:53

@francois-rozet francois-rozet left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @gmoss13, the Unconditional class not being a proper LazyTransform / LazyDistribution has been bugging me for a while. I should fix that 😅 In the mean time, you can create an UnconditionaLazyTransform by subclassing both Unconditional and LazyTransform. See my suggestions.

Comment thread sbi/utils/zukoutils.py Resolved
Comment thread sbi/utils/sbiutils.py Resolved
@gmoss13

gmoss13 commented Mar 22, 2024

Copy link
Copy Markdown
Contributor Author

Hi @francois-rozet, thanks a lot for jumping in with a solution, you beat me to it 😄

@gmoss13
gmoss13 requested a review from manuelgloeckler March 22, 2024 13:10

@Baschdl Baschdl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Guy's changes look good

Comment thread sbi/utils/sbiutils.py Resolved
@Baschdl Baschdl mentioned this pull request Mar 22, 2024
7 of 8 tasks
@gmoss13

gmoss13 commented Mar 24, 2024 •

Copy link
Copy Markdown
Contributor Author

Changing from MonotonicAffineTransform to AffineTransform as suggested by @francois-rozet also fixes the bug in #1091 - @janfb I can merge once you approve 😄

Comment thread sbi/utils/sbiutils.py Resolved
Comment thread sbi/utils/sbiutils.py Resolved

@manuelgloeckler manuelgloeckler left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good from my point of view.

One could add some docs for a few functions, but not necessarily.

@gmoss13

gmoss13 commented Mar 24, 2024

Copy link
Copy Markdown
Contributor Author

Thanks Manuel! Adding docstring and merging!

@gmoss13
gmoss13 merged commit 2567666 into main Mar 24, 2024
@Baschdl Baschdl mentioned this pull request Mar 27, 2024
7 of 8 tasks
@janfb
janfb deleted the 1074-compatibility-fo-lazytransform-and-affinetransform- branch June 20, 2024 10:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Compatibility of LazyTransform and AffineTransform | Unconditional

5 participants