Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Power iteration algorithm is now generic to any linear operator #73

Merged
merged 7 commits into from
Oct 20, 2023

Conversation

cofri
Copy link
Collaborator

@cofri cofri commented May 24, 2023

In order to easily handle power iteration computations for future new linear operators (e.g. depthwise convolution), the power iteration algorithm is made generic:

  • the power iteration function takes a linear operator and its adjoint as arguments
  • for each operation (for now fully connected and convolutional operations), we define their linear and adjoint operators and then use the generic power iteration to compute the maximum singular vector and value.

@cofri cofri requested review from thib-s and franckma31 May 24, 2023 16:44
@cofri cofri force-pushed the refactor/power_iteration_generic branch from 97dcebd to 54a2725 Compare May 25, 2023 10:13
@cofri cofri marked this pull request as ready for review May 26, 2023 08:09
Copy link
Member

@thib-s thib-s left a comment

Choose a reason for hiding this comment

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

check the comment about non square matrices, otherwise LGTM

@franckma31
Copy link
Collaborator

check the comment about non square matrices, otherwise LGTM

To be checked: it seems that it has been resolved for convolution but may also be applicable for dense layer (u of min size in kernel.shape, and use kernel or kernel transpose)

@cofri cofri force-pushed the refactor/power_iteration_generic branch from 99531c7 to ec61e65 Compare October 17, 2023 08:33
@cofri cofri requested review from thib-s and franckma31 October 17, 2023 12:00
Copy link
Member

@thib-s thib-s left a comment

Choose a reason for hiding this comment

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

OK for merge once rebasing is done.

cofri added 7 commits October 20, 2023 11:32
The function `power_iteration()` is now generic to any linear operator.
A linear operator function and its adjoint must be passed as arguments.
The maximum singular vector is returned.

Note that this commit is atomic but is part of larger modifications. It won't
pass the tests as is.
The function `spectral_normalization()` is now based on the generic power
iteration function.
The function spectral_normalization_conv() now uses the generic power iteration.
Unlike spectral normalization for matrices, a get_convolution_operators()
function is introduced because it can be required in some future operations.
Setting the axis for normalization is useful to handle depthwise convolution
filterwise
@cofri cofri force-pushed the refactor/power_iteration_generic branch from 562512a to f09c2be Compare October 20, 2023 09:32
@cofri
Copy link
Collaborator Author

cofri commented Oct 20, 2023

Rebased on master

@cofri cofri merged commit 9781950 into master Oct 20, 2023
@cofri cofri deleted the refactor/power_iteration_generic branch October 20, 2023 13:14
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.

3 participants