-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
fix weight #26986
Conversation
Thanks for your contribution! |
python/paddle/nn/functional/input.py
Outdated
@@ -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]: |
There was a problem hiding this comment.
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])
python/paddle/nn/layer/common.py
Outdated
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: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
同上
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
PR types
Bug fixes
PR changes
APIs
Describe
fix nn.Embedding‘s attr
weight
fix doc