Skip to content

Add exact spectral norm feature#831

Open
lockwo wants to merge 6 commits into
patrick-kidger:mainfrom
lockwo:Owen/spect-norm
Open

Add exact spectral norm feature#831
lockwo wants to merge 6 commits into
patrick-kidger:mainfrom
lockwo:Owen/spect-norm

Conversation

@lockwo

@lockwo lockwo commented Sep 6, 2024

Copy link
Copy Markdown
Contributor

Addresses part of #810.

@lockwo

lockwo commented Sep 6, 2024

Copy link
Copy Markdown
Contributor Author

Open to discussion on best interface. The current caution around bias is ok but could be a footgun (although the original paper doing the reshaping is already kind of a footgun imo lol), but maybe I can apply the linear transpose around the whole layer pytree and update the bias too? I'm not sure that would 100% generalize to all layers though.

Comment thread equinox/nn/_spectral_norm.py Outdated
Comment thread equinox/nn/_spectral_norm.py Outdated
Comment on lines +122 to +126
!!! Caution

If `exact` is true, it computes the transpose via `jax.linear_transpose` of
the layer. This includes all operations of the layer call, which means for
layers with a bias, this can result in the incorrect spectral value.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Maybe we should follow JAX's lead here and transpose the tangent pass of jax.jvp?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hmmm, I tried to implemented what I thought you meant. This also means we could remove the "weight" flag for the exact case (maybe?) since we basically "determine" the weight through the jvp?

Let me know if this is what you had in mind, or if I was totally off. Does seem like a lot of jvps tho.

Comment thread equinox/nn/_spectral_norm.py Outdated
Comment thread equinox/nn/_spectral_norm.py Outdated
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.

2 participants