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

fix weight #26986

Merged
merged 6 commits into from
Sep 8, 2020
Merged

fix weight #26986

merged 6 commits into from
Sep 8, 2020

Conversation

seiriosPlus
Copy link
Collaborator

@seiriosPlus seiriosPlus commented Sep 3, 2020

PR types

Bug fixes

PR changes

APIs

Describe

fix nn.Embedding‘s attr weight
fix doc

@paddle-bot-old
Copy link

paddle-bot-old bot commented Sep 3, 2020

Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@seiriosPlus seiriosPlus closed this Sep 7, 2020
@seiriosPlus seiriosPlus reopened this Sep 7, 2020
@PaddlePaddle PaddlePaddle locked and limited conversation to collaborators Sep 7, 2020
@PaddlePaddle PaddlePaddle unlocked this conversation Sep 7, 2020
@@ -209,6 +210,10 @@ def embedding(x, weight, padding_idx=None, sparse=False, name=None):
padding_idx = -1 if padding_idx is None else padding_idx if padding_idx >= 0 else (
weight.shape[0] + padding_idx)

if padding_idx >= weight.shape[0] or padding_idx <= -weight.shape[0]:
Copy link
Contributor

Choose a reason for hiding this comment

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

开闭区间的处理不对吧?
文档里这么写的:
padding_idx needs to be in the interval [-weight.shape[0], weight.shape[0])

if self._embedding_dim <= 0:
raise ValueError("embedding_dim must be gather than 0")

if self._padding_idx >= num_embeddings or self._padding_idx <= -num_embeddings:
Copy link
Contributor

Choose a reason for hiding this comment

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

同上

Copy link
Contributor

@jzhang533 jzhang533 left a comment

Choose a reason for hiding this comment

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

lgtm

@seiriosPlus seiriosPlus merged commit 5dec254 into PaddlePaddle:develop Sep 8, 2020
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.

None yet

3 participants