-
Notifications
You must be signed in to change notification settings - Fork 19.5k
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
Keras SpectralNormalization and stop_gradient #20309
Comments
I believe this omission came from the fact that
Great! Are you able to open a PR with this fix? |
@hertschuh Apologies for the delay. Yes, I can try to get a PR together. |
PR here: #20353 |
Thanks for the PR! |
Keras Version: 3.5.0
Hello.
A while ago, I had some issues with PyTorch and SpectralNormalization in an RNN layer: #19527
It looks like some things have changed with SpecNorm, but there's something in the code where I'm seeing degraded performance. So degraded, that I'm getting exploding gradients. The difference comes down to some commented-out code in the SpectralNormalization wrapper:
The
stop_gradient()
call is used in both the TF Addons implementation (https://github.com/tensorflow/addons/blob/v0.20.0/tensorflow_addons/layers/spectral_normalization.py#L120-L121) and the official PyTorch implementation (https://pytorch.org/docs/stable/_modules/torch/nn/utils/spectral_norm.html)I've made the change myself by implementing
ops.stop_gradient
at both commented-out spots, and expected (stable) functionality returned.The text was updated successfully, but these errors were encountered: