Skip to content

Realnvp/Nice odd dim#74

Merged
htjb merged 3 commits into
masterfrom
realnvp-odd-dim
Mar 23, 2026
Merged

Realnvp/Nice odd dim#74
htjb merged 3 commits into
masterfrom
realnvp-odd-dim

Conversation

@htjb
Copy link
Copy Markdown
Owner

@htjb htjb commented Mar 23, 2026

Description

Coupling layer flows have been failing for odd numbers of dimensions. In the coupling models we define a pass_size = in_size // 2 where in_size is the number of dimensions and a net_in_size = in_size - pass_size. Then in each layer we split the data in to xa = x[:, :pass_size] and xb = x[:, pass_size:] so xb has shape (len(samples), net_in_size) and xa has shape (len(samples), pass_size). xb is then passed through a neural network that outputs values (s and m in a realnvp) with shapes given by net_in_size. Then when you operate with these outputs on xa you get shape mismatches e.g. in a realnvp you do xa = xa * jnp.exp(s) + m. This works fine for even dimensions because pass_size = net_in_size.

Checklist:

  • I have performed a self-review of my own code
  • New and existing unit tests pass locally with my changes (python -m pytest)
  • I have added tests that prove my fix is effective or that my feature works
  • I have appropriately incremented the semantic version number in both README.rst and margarine/_version.py

@htjb htjb merged commit ca073a9 into master Mar 23, 2026
5 checks passed
@htjb htjb deleted the realnvp-odd-dim branch March 23, 2026 10:47
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.

1 participant