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

Weight Normalization for multi-gpu #1276

Closed
MokkeMeguru opened this issue Mar 10, 2020 · 2 comments
Closed

Weight Normalization for multi-gpu #1276

MokkeMeguru opened this issue Mar 10, 2020 · 2 comments

Comments

@MokkeMeguru
Copy link

Describe the feature and the current behavior/state.

m_init, v_init = tf.nn.moments(x_init, data_norm_axes)

to

ctx = tf.distribute.get_replica_context()
n = ctx.num_replicas_in_sync

m_init = tf.reduce_mean(x_init, axis=data_norm_axes)
v_init = tf.reduce_mean(tf.square(x_init), axis=data_norm_axes)
m_init, v_init = ctx.all_reduce(
    tf.distribute.ReduceOp.SUM,
    [m_init, v_init]
)

m_init = m_init / n
v_init = v_init / n

Relevant information

  • Are you willing to contribute it (yes/no): yes
  • Are you willing to maintain it going forward? (yes/no): yes
  • Is there a relevant academic paper? (if so, where): no
  • Is there already an implementation in another framework? (if so, where): no
  • Was it part of tf.contrib? (if so, where): no

Which API type would this fall under (layer, metric, optimizer, etc.)
Weght Normalization layer
https://github.com/tensorflow/addons/blob/v0.7.1/tensorflow_addons/layers/wrappers.py#L191

Who will benefit with this feature?
Someone wants to train a large model.

Any other info.
Your data-dependent initialization is so GREAT, Thanks

@WindQAQ
Copy link
Member

WindQAQ commented Apr 24, 2020

@MokkeMeguru This is a fair change :-) Feel free to open a PR for it. Thanks.

https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/keras/layers/normalization_v2.py#L32

@seanpmorgan
Copy link
Member

TensorFlow Addons is transitioning to a minimal maintenance and release mode. New features will not be added to this repository. For more information, please see our public messaging on this decision:
TensorFlow Addons Wind Down

Please consider sending feature requests / contributions to other repositories in the TF community with a similar charters to TFA:
Keras
Keras-CV
Keras-NLP

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

No branches or pull requests

4 participants