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

SpectralNormalization #17648

Closed
wants to merge 6 commits into from
Closed

Conversation

markub3327
Copy link
Contributor

Hello,

here is the adapted SpectralNormalization from TF-Addons implementation.

Thanks.

@gbaned gbaned requested a review from fchollet March 9, 2023 17:12
@google-ml-butler google-ml-butler bot added the keras-team-review-pending Pending review by a Keras team member. label Mar 9, 2023
@qlzh727 qlzh727 removed the keras-team-review-pending Pending review by a Keras team member. label Mar 9, 2023
@fchollet
Copy link
Member

Thanks for the PR!

We have recently ported a number of classes from TFAddons to core Keras. However for each class we ended up doing pretty extensive style changes and we increased test coverage. If we were to bring SpectralNormalization into Keras it would require further work.

However I am not sure we should do it. Our observation was that SpectralNormalization was getting very little usage, in terms of pageviews to the TFAddons docs. It didn't seem to meet our threshold for the kind of APIs we host in core Keras. Are you aware of any important use cases?

@markub3327
Copy link
Contributor Author

markub3327 commented Mar 13, 2023

@fchollet

I think it is a useful layer. Please look at paper: https://arxiv.org/abs/1802.05957.
It's cited by 3797.

PyTorch includes by default: https://paperswithcode.com/paper/spectral-normalization-for-generative

Copy link
Member

@fchollet fchollet left a comment

Choose a reason for hiding this comment

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

Sounds good -- the citation count is pretty convincing.

keras/layers/normalization/spectral_normalization.py Outdated Show resolved Hide resolved
keras/layers/normalization/spectral_normalization.py Outdated Show resolved Hide resolved
)

def get_config(self):
config = {"power_iterations": self.power_iterations}
Copy link
Member

Choose a reason for hiding this comment

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

If it doesn't include the layer being wrapped, it won't properly deserialize. Is this tested?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Only power_iterations was tested.

keras/layers/normalization/spectral_normalization_test.py Outdated Show resolved Hide resolved
keras/layers/normalization/spectral_normalization.py Outdated Show resolved Hide resolved
keras/layers/normalization/spectral_normalization.py Outdated Show resolved Hide resolved
keras/layers/normalization/spectral_normalization.py Outdated Show resolved Hide resolved
keras/layers/normalization/spectral_normalization.py Outdated Show resolved Hide resolved
@google-ml-butler google-ml-butler bot added the keras-team-review-pending Pending review by a Keras team member. label Mar 13, 2023
@mattdangerw mattdangerw removed the keras-team-review-pending Pending review by a Keras team member. label Mar 16, 2023
Copy link
Member

@fchollet fchollet left a comment

Choose a reason for hiding this comment

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

Thanks for the update! Looking good. Some minor nits.

keras/layers/normalization/spectral_normalization.py Outdated Show resolved Hide resolved
keras/layers/normalization/spectral_normalization.py Outdated Show resolved Hide resolved
@google-ml-butler google-ml-butler bot added the keras-team-review-pending Pending review by a Keras team member. label Mar 21, 2023
Copy link
Member

@fchollet fchollet left a comment

Choose a reason for hiding this comment

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

LGTM, thank you for the contribution!

@google-ml-butler google-ml-butler bot added kokoro:force-run ready to pull Ready to be merged into the codebase labels Mar 23, 2023
@fchollet fchollet removed the keras-team-review-pending Pending review by a Keras team member. label Mar 23, 2023
@google-ml-butler google-ml-butler bot added keras-team-review-pending Pending review by a Keras team member. and removed ready to pull Ready to be merged into the codebase labels Mar 24, 2023
@markub3327
Copy link
Contributor Author

@haifeng-jin All is repaired. Thanks.

@google-ml-butler google-ml-butler bot added the keras-team-review-pending Pending review by a Keras team member. label Mar 28, 2023
copybara-service bot pushed a commit that referenced this pull request Mar 28, 2023
Imported from GitHub PR #17648

Hello,

  here is the adapted `SpectralNormalization` from TF-Addons implementation.

Thanks.
Copybara import of the project:

--
0ae1ae7 by Martin Kubovcik <markub3327@gmail.com>:

+ SpectralNormalization

--
7f91062 by Martin Kubovcik <markub3327@gmail.com>:

fixes

--
5fbe19e by Martin Kubovcik <markub3327@gmail.com>:

fix

--
f57b45a by Martin Kubovcik <markub3327@gmail.com>:

update

--
46269ea by Martin Kubovcik <markub3327@gmail.com>:

update tests

Merging this change closes #17648

FUTURE_COPYBARA_INTEGRATE_REVIEW=#17648 from markub3327:keras-update 46269ea
PiperOrigin-RevId: 519773515
copybara-service bot pushed a commit that referenced this pull request Mar 28, 2023
Imported from GitHub PR #17648

Hello,

  here is the adapted `SpectralNormalization` from TF-Addons implementation.

Thanks.
Copybara import of the project:

--
0ae1ae7 by Martin Kubovcik <markub3327@gmail.com>:

+ SpectralNormalization

--
7f91062 by Martin Kubovcik <markub3327@gmail.com>:

fixes

--
5fbe19e by Martin Kubovcik <markub3327@gmail.com>:

fix

--
f57b45a by Martin Kubovcik <markub3327@gmail.com>:

update

--
46269ea by Martin Kubovcik <markub3327@gmail.com>:

update tests

Merging this change closes #17648

FUTURE_COPYBARA_INTEGRATE_REVIEW=#17648 from markub3327:keras-update 46269ea
PiperOrigin-RevId: 519773515
copybara-service bot pushed a commit that referenced this pull request Mar 28, 2023
Imported from GitHub PR #17648

Hello,

  here is the adapted `SpectralNormalization` from TF-Addons implementation.

Thanks.
Copybara import of the project:

--
0ae1ae7 by Martin Kubovcik <markub3327@gmail.com>:

+ SpectralNormalization

--
7f91062 by Martin Kubovcik <markub3327@gmail.com>:

fixes

--
5fbe19e by Martin Kubovcik <markub3327@gmail.com>:

fix

--
f57b45a by Martin Kubovcik <markub3327@gmail.com>:

update

--
46269ea by Martin Kubovcik <markub3327@gmail.com>:

update tests

Merging this change closes #17648

FUTURE_COPYBARA_INTEGRATE_REVIEW=#17648 from markub3327:keras-update 46269ea
PiperOrigin-RevId: 519773515
copybara-service bot pushed a commit that referenced this pull request Mar 28, 2023
Imported from GitHub PR #17648

Hello,

  here is the adapted `SpectralNormalization` from TF-Addons implementation.

Thanks.
Copybara import of the project:

--
0ae1ae7 by Martin Kubovcik <markub3327@gmail.com>:

+ SpectralNormalization

--
7f91062 by Martin Kubovcik <markub3327@gmail.com>:

fixes

--
5fbe19e by Martin Kubovcik <markub3327@gmail.com>:

fix

--
f57b45a by Martin Kubovcik <markub3327@gmail.com>:

update

--
46269ea by Martin Kubovcik <markub3327@gmail.com>:

update tests

Merging this change closes #17648

FUTURE_COPYBARA_INTEGRATE_REVIEW=#17648 from markub3327:keras-update 46269ea
PiperOrigin-RevId: 519773515
copybara-service bot pushed a commit that referenced this pull request Mar 28, 2023
copybara-service bot pushed a commit to tensorflow/tensorflow that referenced this pull request Mar 28, 2023
Imported from GitHub PR keras-team/keras#17648

Hello,

  here is the adapted `SpectralNormalization` from TF-Addons implementation.

Thanks.
Copybara import of the project:

--
0ae1ae70024b548fc2aee47c976ca4c30530157f by Martin Kubovcik <markub3327@gmail.com>:

+ SpectralNormalization

--
7f91062eea8d23f6407a2c3bc253e82e48a52e30 by Martin Kubovcik <markub3327@gmail.com>:

fixes

--
5fbe19ecadbdf69acb13f1b3aac3c411b1427c83 by Martin Kubovcik <markub3327@gmail.com>:

fix

--
f57b45aa5a635a3d75ec957e9ca3f7ce5984421c by Martin Kubovcik <markub3327@gmail.com>:

update

--
46269ea5fc5d404051c47a7eadcd42acd2a62ad6 by Martin Kubovcik <markub3327@gmail.com>:

update tests

Merging this change closes #17648

PiperOrigin-RevId: 520171696
@rchao
Copy link
Contributor

rchao commented Mar 30, 2023

@haifeng-jin mind taking a look what's being blocked here?

@rchao rchao removed the keras-team-review-pending Pending review by a Keras team member. label Mar 30, 2023
@haifeng-jin
Copy link
Contributor

@rchao Seems it is merged by copybara here, but somehow the PR is not merged.

@haifeng-jin
Copy link
Contributor

Probably, we should just click "Merge pull request" here since copybara missed it.
Anyone who has the permission may help.

@gbaned gbaned removed the ready to pull Ready to be merged into the codebase label Apr 6, 2023
@google-ml-butler google-ml-butler bot added kokoro:force-run ready to pull Ready to be merged into the codebase labels Apr 6, 2023
@gbaned gbaned added ready to pull Ready to be merged into the codebase and removed ready to pull Ready to be merged into the codebase labels Apr 10, 2023
@google-ml-butler google-ml-butler bot removed the ready to pull Ready to be merged into the codebase label Apr 12, 2023
@markub3327 markub3327 deleted the keras-update branch April 13, 2023 18:31
@milmor
Copy link

milmor commented Jun 27, 2023

Are you sure this spectral normalization works correctly? It seems like it's the same tfa implementation, which is wrong @fchollet

tensorflow/addons#2414

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants