Repository navigation
Conversation
Add MultiscaleFlow.pcf_regularizer(x, num_dims=1, create_graph=None),
the penalty of principal component flows (Cunningham, Cobb and Jha,
ICML 2022) with single-coordinate partitions:
-I_hat(x) = sum_k log||dz_k/dx|| - log|det dz/dx| >= 0,
which is zero when the rows of the encoder Jacobian are orthogonal
(Hadamard's inequality), i.e. when the flow's contours are its
principal manifolds. Train with
loss = -log p(x) + alpha * pcf_regularizer(x).
The sum over latent coordinates is estimated without bias by stratified
sampling: num_dims coordinates per level and per sample, each costing
one vector-Jacobian product through the encoder, weighted by the level
size. A level is summed exactly when num_dims >= its size. The graph is
kept for double backward when the model is training.
Tests (tests/pcf_test.py): exact mode matches the full-Jacobian value
and is non-negative; the stochastic estimate is unbiased; the penalty
is zero for an orthogonal encoder; gradients are finite with and
without gradient checkpointing; num_dims < 1 is rejected.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add MultiscaleFlow.pcf_regularizer(x, num_dims=1, create_graph=None), the penalty of principal component flows (Cunningham, Cobb and Jha, ICML 2022) with single-coordinate partitions:
which is zero when the rows of the encoder Jacobian are orthogonal (Hadamard's inequality), i.e. when the flow's contours are its principal manifolds. Train with
loss = -log p(x) + alpha * pcf_regularizer(x).
The sum over latent coordinates is estimated without bias by stratified sampling: num_dims coordinates per level and per sample, each costing one vector-Jacobian product through the encoder, weighted by the level size. A level is summed exactly when num_dims >= its size. The graph is kept for double backward when the model is training.
Tests (tests/pcf_test.py): exact mode matches the full-Jacobian value and is non-negative; the stochastic estimate is unbiased; the penalty is zero for an orthogonal encoder; gradients are finite with and without gradient checkpointing; num_dims < 1 is rejected.