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

[New Feature]add normalized_emb #443

Merged
merged 1 commit into from
Jul 6, 2024
Merged

[New Feature]add normalized_emb #443

merged 1 commit into from
Jul 6, 2024

Conversation

jq
Copy link
Collaborator

@jq jq commented Jul 2, 2024

Description

add DynamicLayerNormalization since tf LayerNormalization doesn't support dynamic shape

Brief Description of the PR:

Fixes # (issue)

Type of change

  • Bug fix
  • New Tutorial
  • Updated or additional documentation
  • Additional Testing
  • New Feature

Checklist:

  • I've properly formatted my code according to the guidelines
    • By running yapf
    • By running clang-format
  • This PR addresses an already submitted issue for TensorFlow Recommenders-Addons
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works

How Has This Been Tested?

If you're adding a bugfix or new feature please describe the tests that you ran to verify your changes:
*

@@ -240,6 +241,100 @@ def get_kv_creator(mpi_size: int,
return de.CuckooHashTableCreator(saver=saver)


class DynamicLayerNormalization(LayerNormalization):
Copy link
Member

Choose a reason for hiding this comment

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

Cool! It is really useful, and I recommend this layer could be a regular API, not only a demo.

from tensorflow.keras.layers import LayerNormalization


class DynamicLayerNormalization(LayerNormalization):
Copy link
Member

Choose a reason for hiding this comment

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

It is recommended to keep the name of LayerNormalization and just use a different prefix sort of de.keras.layers.LayerNormalization. Accordingly, the import statement needs to be modified to from tensorflow.keras.layers import TFLayerNormalization

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

you mean from tensorflow.keras.layers import LayerNormalization as TFLayerNormalization ?

Copy link
Member

Choose a reason for hiding this comment

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

Correct! And using de.keras.layers.LayerNormalization

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

how about de.LayerNormalization?

DynamicLayerNormalization


class DynamicLayerNormalizationTest(tf.test.TestCase):
Copy link
Member

Choose a reason for hiding this comment

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

We'd better to have one case testing the scenario in which the new layer works with tfra API like the demo shows.

Copy link
Member

@rhdong rhdong left a comment

Choose a reason for hiding this comment

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

LGTM

@rhdong rhdong merged commit e30aa41 into tensorflow:master Jul 6, 2024
42 checks passed
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.

2 participants