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
Feature request: weight normalization #10125
Comments
@rmlarsen Any thoughts on this feature request? |
@appierys that's just a link to a file with helper utilities, there no actual implementation of the algorithm there |
@yaroslavvb I do think the file contains the implementation of WN. For example, here is the implementation of weight norm in a fully connected layer: https://github.com/openai/weightnorm/blob/master/tensorflow/nn.py#L166 |
@appierys that indeed looks like one of the formulas, but some other ones are missing. (ie, equation for updating the step length parameter) |
Hi Our implementation is based on which requires a few lines of additional code in tensorflow core. This is because in the current setup (dynamic_rnn etc.) RNN weights are created via the cell's call() function which is called from within tf.while(). Based on the above link, weight-normalised cells require weight creation and normalisation before entering the while loop. This may not be the best way to implement it, but for the moment we have sent in a pull request: We'd be keen to hear your thoughts and/or to engage in further testing/discussing a different implementation structure. |
It has been 14 days with no activity and the |
We'd be interested in considering a contribution adding this support. |
@discoveredcheck Thanks for your contribution, and I have read your PR about "WeightNormLSTMCell". I notice that you define variables in the functions self._linear and self._normalize, and do not set tf.AUTO_REUSE flag. So, I wonder how to ensure the variables are reused when self.call are invoked multiple times? I test your code, and it works well. I just want to know how it works. |
@llan-ml Apologies for the late reply. Hope this helps. Ashwini |
Thanks for your explanations @discoveredcheck. On the other hand, to enable weight normalization for dense and convolutional layers, can we just add the weight normalization in the kernel = self.add_variable("kernel", ...) if self._weight_norm: g = self.add_variable("wn/g", ...) self.kernel = nn_impl.l2_normalize(kernel, axis=0) * g else: self.kernel = kernel Similar modifications could be also made for |
Yes, adding the weight-norm update in Your link, however, revers to L152 which is inside |
Yeah, it should be L132, and I have corrected the link. |
I write some simple wrappers for dense and conv2d layers with weight normalization. |
Fix spelling.. Fix eager run without data_init
Thanks, Sean :-) |
Is it possible to incorporate Weight Normalization (https://arxiv.org/abs/1602.07868) into tensorflow itself?
https://github.com/openai/weightnorm/tree/master/tensorflow
The text was updated successfully, but these errors were encountered: