-
Notifications
You must be signed in to change notification settings - Fork 764
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
映射文档 No. 54 #5852
Merged
Merged
映射文档 No. 54 #5852
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
...guides/model_convert/convert_from_pytorch/api_difference/nn/torch.nn.CTCLoss.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# [torch 参数更多]torch.nn.CTCLoss | ||
|
||
### [torch.nn.CTCLoss](https://pytorch.org/docs/1.13/generated/torch.nn.CTCLoss.html#torch.nn.CTCLoss) | ||
|
||
```python | ||
torch.nn.CTCLoss(blank=0, | ||
reduction='mean', | ||
zero_infinity=False) | ||
``` | ||
|
||
### [paddle.nn.CTCLoss](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/nn/CTCLoss_cn.html#ctcloss) | ||
|
||
```python | ||
paddle.nn.CTCLoss(blank=0, | ||
reduction='mean') | ||
``` | ||
|
||
Pytorch 相比 Paddle 支持在损失函数值为无穷大时将损失值及其梯度置为 0,paddle 暂无此功能,具体如下: | ||
|
||
### 参数映射 | ||
|
||
| PyTorch | Paddle | 备注 | | ||
| ------------- | --------- | ------------------------------------------------------------ | | ||
| blank | blank | 空格标记的 ID 值。 | | ||
| reduction | reduction | 表示应用于输出结果的计算方式。 | | ||
| zero_infinity | - | 是否将无穷大损失及其梯度置 0,Paddle 无此参数,需要转写,paddle 暂无转写方式。 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
...l_convert/convert_from_pytorch/api_difference/nn/torch.nn.HingeEmbeddingLoss.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# [torch 参数更多]torch.nn.HingeEmbeddingLoss | ||
|
||
### [torch.nn.HingeEmbeddingLoss](https://pytorch.org/docs/1.13/generated/torch.nn.HingeEmbeddingLoss.html#hingeembeddingloss) | ||
|
||
```python | ||
torch.nn.HingeEmbeddingLoss(margin=1.0, | ||
size_average=None, | ||
reduce=None, | ||
reduction='mean') | ||
``` | ||
|
||
### [paddle.nn.HingeEmbeddingLoss](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/nn/HingeEmbeddingLoss_cn.html#hingeembeddingloss) | ||
|
||
```python | ||
paddle.nn.HingeEmbeddingLoss(margin=1.0, | ||
reduction='mean', | ||
name=None) | ||
``` | ||
|
||
Pytorch 相比 Paddle 支持更多其他参数,具体如下: | ||
|
||
### 参数映射 | ||
|
||
| PyTorch | Paddle | 备注 | | ||
| ------------ | --------- | ------------------------------------------------------------ | | ||
| margin | margin | 当 label 为-1 时,该值决定了小于 margin 的 input 才需要纳入 hinge embedding loss 的计算。 | | ||
| size_average | - | PyTorch 已弃用, Paddle 无此参数,需要转写。 | | ||
| reduce | - | PyTorch 已弃用, Paddle 无此参数,需要转写。 | | ||
| reduction | reduction | 表示应用于输出结果的计算方式。 | | ||
|
||
### 转写示例 | ||
|
||
#### size_average | ||
|
||
```python | ||
# Pytorch 的 size_average、reduce 参数转为 Paddle 的 reduction 参数 | ||
if size_average is None: | ||
size_average = True | ||
if reduce is None: | ||
reduce = True | ||
|
||
if size_average and reduce: | ||
reduction = 'mean' | ||
elif reduce: | ||
reduction = 'sum' | ||
else: | ||
reduction = 'none' | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
...el_convert/convert_from_pytorch/api_difference/nn/torch.nn.MarginRankingLoss.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# [torch 参数更多]torch.nn.MarginRankingLoss | ||
|
||
### [torch.nn.MarginRankingLoss](https://pytorch.org/docs/1.13/generated/torch.nn.MarginRankingLoss.html#marginrankingloss) | ||
|
||
```python | ||
torch.nn.MarginRankingLoss(margin=0.0, | ||
size_average=None, | ||
reduce=None, | ||
reduction='mean') | ||
``` | ||
|
||
### [paddle.nn.MarginRankingLoss](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/nn/MarginRankingLoss_cn.html#marginrankingloss) | ||
|
||
```python | ||
paddle.nn.MarginRankingLoss(margin=0.0, | ||
reduction='mean', | ||
name=None) | ||
``` | ||
|
||
Pytorch 相比 Paddle 支持更多其他参数,具体如下: | ||
|
||
### 参数映射 | ||
|
||
| PyTorch | Paddle | 备注 | | ||
| ------------ | --------- | -------------------------------------------- | | ||
| margin | margin | 用于加和的 margin 值。 | | ||
| size_average | - | PyTorch 已弃用, Paddle 无此参数,需要转写。 | | ||
| reduce | - | PyTorch 已弃用, Paddle 无此参数,需要转写。 | | ||
| reduction | reduction | 表示应用于输出结果的计算方式。 | | ||
|
||
### 转写示例 | ||
|
||
#### size_average | ||
|
||
```python | ||
# Pytorch 的 size_average、reduce 参数转为 Paddle 的 reduction 参数 | ||
if size_average is None: | ||
size_average = True | ||
if reduce is None: | ||
reduce = True | ||
|
||
if size_average and reduce: | ||
reduction = 'mean' | ||
elif reduce: | ||
reduction = 'sum' | ||
else: | ||
reduction = 'none' | ||
``` |
48 changes: 48 additions & 0 deletions
48
...guides/model_convert/convert_from_pytorch/api_difference/nn/torch.nn.NLLLoss.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# [torch 参数更多]torch.nn.NLLLoss | ||
|
||
### [torch.nn.NLLLoss](https://pytorch.org/docs/1.13/generated/torch.nn.NLLLoss.html?highlight=nllloss#torch.nn.NLLLoss) | ||
|
||
```python | ||
torch.nn.NLLLoss(weight=None, | ||
size_average=None, | ||
ignore_index=- 100, | ||
reduce=None, | ||
reduction='mean') | ||
``` | ||
|
||
### [paddle.nn.NLLLoss](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/nn/NLLLoss_cn.html#nllloss) | ||
|
||
```python | ||
paddle.nn.NLLLoss(weight=None, | ||
ignore_index=- 100, | ||
reduction='mean', | ||
name=None) | ||
``` | ||
|
||
Pytorch 相比 Paddle 支持更多其他参数,具体如下: | ||
|
||
### 参数映射 | ||
| PyTorch | Paddle | 备注 | | ||
| ------------ | ------------ | -------------------------------------------- | | ||
| weight | weight | 表示每个类别的权重。 | | ||
| size_average | - | PyTorch 已弃用, Paddle 无此参数,需要转写。 | | ||
| ignore_index | ignore_index | 表示忽略的一个标签值。 | | ||
| reduce | - | PyTorch 已弃用, Paddle 无此参数,需要转写。 | | ||
| reduction | reduction | 表示应用于输出结果的计算方式。 | | ||
|
||
### 转写示例 | ||
#### size_average | ||
```python | ||
# Pytorch 的 size_average、reduce 参数转为 Paddle 的 reduction 参数 | ||
if size_average is None: | ||
size_average = True | ||
if reduce is None: | ||
reduce = True | ||
|
||
if size_average and reduce: | ||
reduction = 'mean' | ||
elif reduce: | ||
reduction = 'sum' | ||
else: | ||
reduction = 'none' | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
...model_convert/convert_from_pytorch/api_difference/nn/torch.nn.SoftMarginLoss.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# [torch 参数更多]torch.nn.SoftMarginLoss | ||
|
||
### [torch.nn.SoftMarginLosss](https://pytorch.org/docs/1.13/generated/torch.nn.SoftMarginLoss.html#torch.nn.SoftMarginLoss) | ||
|
||
```python | ||
torch.nn.SoftMarginLoss(size_average=None, | ||
reduce=None, | ||
reduction='mean') | ||
``` | ||
|
||
### [paddle.nn.SoftMarginLoss](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/nn/SoftMarginLoss_cn.html#softmarginloss) | ||
|
||
```python | ||
paddle.nn.SoftMarginloss(reduction='mean', | ||
name=None) | ||
``` | ||
|
||
Pytorch 相比 Paddle 支持更多其他参数,具体如下: | ||
|
||
### 参数映射 | ||
|
||
| PyTorch | Paddle | 备注 | | ||
| ------------ | --------- | -------------------------------------------- | | ||
| size_average | - | PyTorch 已弃用, Paddle 无此参数,需要转写。 | | ||
| reduce | - | PyTorch 已弃用, Paddle 无此参数,需要转写。 | | ||
| reduction | reduction | 表示应用于输出结果的计算方式。 | | ||
|
||
### 转写示例 | ||
|
||
#### size_average | ||
|
||
```python | ||
# Pytorch 的 size_average、reduce 参数转为 Paddle 的 reduction 参数 | ||
if size_average is None: | ||
size_average = True | ||
if reduce is None: | ||
reduce = True | ||
|
||
if size_average and reduce: | ||
reduction = 'mean' | ||
elif reduce: | ||
reduction = 'sum' | ||
else: | ||
reduction = 'none' | ||
``` |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
这里直接写
其中,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.
你好,已修改👌