-
Notifications
You must be signed in to change notification settings - Fork 724
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
Update Embedding doc #6806
base: develop
Are you sure you want to change the base?
Update Embedding doc #6806
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ torch.nn.functional.embedding(input, weight, padding_idx=None, max_norm=None, no | |
### [paddle.nn.functional.embedding](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/nn/functional/embedding_cn.html#embedding) | ||
|
||
```python | ||
paddle.nn.functional.embedding(x, weight, padding_idx=None, sparse=False, name=None) | ||
paddle.nn.functional.embedding(x, weight, padding_idx=None, max_norm=None, norm_type=2.0, sparse=False, name=None) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 分类类别:torch参数更多->仅参数名不一致 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这个的话,scale_grad_by_freq参数暂时还不支持,应该不用修改吧 |
||
``` | ||
|
||
PyTorch 相比 Paddle 支持更多其他参数,具体如下: | ||
|
@@ -21,7 +21,7 @@ PyTorch 相比 Paddle 支持更多其他参数,具体如下: | |
| input | x | 输入 Tensor,仅参数名不同。 | | ||
| weight | weight | 嵌入矩阵权重。 | | ||
| padding_idx | padding_idx | 视为填充的下标,参数完全一致。 | | ||
| max_norm | - | 重新归一化的最大范数,参数不一致,暂无转写方式。 | | ||
| norm_type | - | Paddle 无此参数,参数不一致,暂无转写方式。 | | ||
| max_norm | max_norm | 重新归一化的最大范数,参数完全一致。 | | ||
| norm_type | norm_type | 范数计算方式,默认为 L2 范数,参数完全一致。 | | ||
| scale_grad_by_freq | - | 按词频进行梯度缩放的比例,参数不一致,暂无转写方式。 | | ||
| sparse | sparse | 是否使用稀疏更新。 | |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,8 @@ torch.nn.Embedding(num_embeddings, | |
paddle.nn.Embedding(num_embeddings, | ||
embedding_dim, | ||
padding_idx=None, | ||
max_norm=None, | ||
norm_type=2.0, | ||
sparse=False, | ||
weight_attr=None, | ||
name=None) | ||
|
@@ -29,8 +31,8 @@ PyTorch 相比 Paddle 支持更多其他参数,具体如下: | |
| num_embeddings | num_embeddings | 表示嵌入字典的大小。 | | ||
| embedding_dim | embedding_dim | 表示每个嵌入向量的维度。 | | ||
| padding_idx | padding_idx | 在此区间内的参数及对应的梯度将会以 0 进行填充 | | ||
| max_norm | - | 如果给定,Embeddding 向量的范数(范数的计算方式由 norm_type 决定)超过了 max_norm 这个界限,就要再进行归一化,Paddle 无此参数,暂无转写方式。 | | ||
| norm_type | - | 为 maxnorm 选项计算 p-范数的 p。默认值 2,Paddle 无此参数,暂无转写方式。 | | ||
| max_norm | max_norm | 如果给定,Embeddding 向量的范数(范数的计算方式由 norm_type 决定)超过了 max_norm 这个界限,就要再进行归一化。 | | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 分类类别:torch参数更多->仅参数名不一致 |
||
| norm_type | norm_type | 为 maxnorm 选项计算 p-范数的 p。默认值 2。 | | ||
| scale_grad_by_freq | - | 是否根据单词在 mini-batch 中出现的频率,对梯度进行放缩,Paddle 无此参数,暂无转写方式。 | | ||
| sparse | sparse | 表示是否使用稀疏更新。 | | ||
| - | weight_attr | 指定权重参数属性的对象,PyTorch 无此参数,Paddle 保持默认即可。 | |
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.
有一个其他Bug,不影响本文档合入。
在静态图下,是否会导致梯度无法计算,因为返回了一个新的weight。这个应该写为:
保证是原来的weight参与组网计算与反向传播,返回一个新的weight,当前weight就从网络中分离了。这个静态图的问题需要修一下 @AndPuQing
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.
这样的话,静态图的renorm 是不是就失效了