Skip to content

映射文档 torch.nn.functional.embedding #5928

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

Open
wants to merge 11 commits into
base: develop
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
add convert_from_pytoch function.embedding md
  • Loading branch information
LokeZhou committed Jun 9, 2023
commit dd20f51d096b024bf7cdc385f9380d3071fa3f52
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
## [ torch 参数更多 ]torch.nn.functional.embedding
### [torch.nn.functional.embedding](https://pytorch.org/docs/stable/generated/torch.nn.functional.embedding.html?highlight=torch+nn+functional+embedding#torch.nn.functional.embedding)

```python
torch.nn.functional.embedding(input,
weight,
padding_idx=None,
max_norm=None,
norm_type=2.0,
scale_grad_by_freq=False,
sparse=False)
```
### [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)
```

其中 Pytorch 相比 Paddle 支持更多其他参数,具体如下:
### 参数映射
| PyTorch | PaddlePaddle | 备注 |
| ------------- | ------------ | ------------------------------------------------------ |
| input | x | 表示存储id信息的Tensor |
| weight | weight | 表示存储词嵌入权重参数的 Tensor |
| padding_idx | padding_idx | 在此区间内的参数及对应的梯度将会以 0 进行填充 |
| max_norm | - | 如果给定,Embeddding 向量的范数(范数的计算方式由 norm_type 决定)超过了 max_norm 这个界限,就要再进行归一化,PaddlePaddle 无此功能,暂无转写方式。 |
| norm_type | - | 为 maxnorm 选项计算 p-范数的 p。默认值 2,PaddlePaddle 暂无此功能,暂无转写方式。 |
| scale_grad_by_freq | - | 是否根据单词在 mini-batch 中出现的频率,对梯度进行放缩,PaddlePaddle 暂无此功能。 |
Copy link
Collaborator

Choose a reason for hiding this comment

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

少了个 暂无转写方式。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Collaborator

Choose a reason for hiding this comment

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

写成统一一致的吧:暂无转写方式

| sparse | sparse | 表示是否使用稀疏更新。 |
| - | name | Pytorch 无此参数,Paddle 保持默认即可。 |
Copy link
Collaborator

Choose a reason for hiding this comment

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

所有API的name参数,都忽略即可

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done