Skip to content

Conversation

amantayal44
Copy link
Contributor

@amantayal44 amantayal44 commented Mar 23, 2022

Resolves #26

@google-cla
Copy link

google-cla bot commented Mar 23, 2022

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

For more information, open the CLA check for this pull request.

@mattdangerw mattdangerw self-requested a review March 24, 2022 02:51
@amantayal44 amantayal44 force-pushed the master branch 2 times, most recently from 95b81af to 4a1372a Compare March 24, 2022 07:31
@amantayal44
Copy link
Contributor Author

Hey @mattdangerw, any update on this?

Copy link
Member

@mattdangerw mattdangerw left a comment

Choose a reason for hiding this comment

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

Thank you! Left some initial comments.

@amantayal44
Copy link
Contributor Author

@mattdangerw, updated all the changes requested.

Copy link
Member

@mattdangerw mattdangerw left a comment

Choose a reason for hiding this comment

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

Thanks! Few more comments.

Copy link
Contributor

@chenmoneygithub chenmoneygithub 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 PR! The calculation looks good to me, left some initial comments.

@amantayal44
Copy link
Contributor Author

@mattdangerw have small doubt when adding changes requested, should we do force push amending previous commit or create a new commit?

@mattdangerw
Copy link
Member

@amantayal44 either is fine. We recently switched our merge strategy to "Squash and Merge", so you can keep a long commit history here of each round of review which will get squashed before going to master.

Also, re the argument name I saw you and Chen were discussing... I think the framing that will be most recognizable to users would be the exact framing from the Attention is All You Need paper, with the constant 10000 specifically. So switching this to wavelength instead of frequency. What do you think?

Most explainers I see out on the web use wavelength, and most implementations use 10K as a magic constant. Here's what the docstring could look like:

max_wavelength: The maximum angular wavelength of the sine/cosine curves, as 
    described in Attention is All You Need. Defaults to 10000.

def __init__(
    self,
    max_wavelength=10000,
    **kwargs,
)

Besides that, this lgtm!

@amantayal44
Copy link
Contributor Author

@amantayal44 either is fine. We recently switched our merge strategy to "Squash and Merge", so you can keep a long commit history here of each round of review which will get squashed before going to master.

Also, re the argument name I saw you and Chen were discussing... I think the framing that will be most recognizable to users would be the exact framing from the Attention is All You Need paper, with the constant 10000 specifically. So switching this to wavelength instead of frequency. What do you think?

Most explainers I see out on the web use wavelength, and most implementations use 10K as a magic constant. Here's what the docstring could look like:

max_wavelength: The maximum angular wavelength of the sine/cosine curves, as 
    described in Attention is All You Need. Defaults to 10000.

def __init__(
    self,
    max_wavelength=10000,
    **kwargs,
)

Besides that, this lgtm!

yes, max_wavelength will be much better.

@mattdangerw
Copy link
Member

mattdangerw commented Mar 30, 2022

@amantayal44 oops just noticed one more thing while merging. The filename no longer matches the class name.

Can you rename sine_positional_embedding.py -> sine_position_encoding.py, sine_positional_embedding_test.py -> sine_position_encoding_test.py, and fix the __init__.py import?

Then really good to go I think 😄

@amantayal44
Copy link
Contributor Author

@amantayal44 oops just noticed one more thing while merging. The filename no longer matches the class name.

Can you rename sine_positional_embedding.py -> sine_position_encoding.py, sine_positional_embedding_test.py -> sine_position_encoding_test.py, and fix the __init__.py import?

Then really good to go I think 😄

done!! 😅

@mattdangerw
Copy link
Member

Thank you!!

@mattdangerw mattdangerw merged commit 972eaec into keras-team:master Mar 30, 2022
adhadse pushed a commit to adhadse/keras-nlp that referenced this pull request Sep 17, 2022
* Add a sinusoidal embedding layer

* renamed  min_frequency to base_frequency and updated docstring

* changed base_frequency to max_wavelength and added test to check correct values

* renamed files

* Fixup docstring formatting

Co-authored-by: Matt Watson <1389937+mattdangerw@users.noreply.github.com>
mattdangerw pushed a commit that referenced this pull request May 21, 2024
mattdangerw pushed a commit that referenced this pull request May 21, 2024
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.

Add a sinusoidal embedding layer
3 participants