-
Notifications
You must be signed in to change notification settings - Fork 764
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 新增5个api映射文档,修改5个原有文档的内容 * modify torch.nn.CTCLoss.md
- Loading branch information
1 parent
4da15bc
commit e6800c7
Showing
10 changed files
with
231 additions
and
16 deletions.
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 支持更多其他参数,具体如下: | ||
|
||
### 参数映射 | ||
|
||
| 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' | ||
``` |