Skip to content
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

【Hackathon 5th No.43】API转换21-41 -part #6280

Merged
merged 5 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions docs/api/paddle/nn/PoissonNLLLoss_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
PoissonNLLLoss
-------------------------------

.. py:class:: paddle.nn.PoissonNLLLoss(log_input=True, full=False, eps=1e-8, reduction='mean', name=None)
.. py:class:: paddle.nn.PoissonNLLLoss(log_input=True, full=False, epsilon=1e-8, reduction='mean', name=None)

该接口可创建一个 PoissonNLLLoss 可调用类,计算输入 :attr:`input` 和标签 :attr:`label` 间的 `Poisson negative log likelihood loss` 损失。该 loss 适用于真实标签服从于泊松分布时,即

Expand All @@ -14,9 +14,9 @@ PoissonNLLLoss
当 `log_input` 设置为 `True` 时,损失函数的数学计算公式为:

.. math::
\text{loss}(\text{input}, \text{label}) = \text{input} - \text{label} * \log(\text{input}+\text{eps}) + \log(\text{label!})
\text{loss}(\text{input}, \text{label}) = \text{input} - \text{label} * \log(\text{input}+\text{epsilon}) + \log(\text{label!})

其中 `eps` 是 ``True`` 时使用的常数小量,使得 loss 计算过程中不会导致对 0 求对数情况的出现。
其中 `epsilon` 是 ``True`` 时使用的常数小量,使得 loss 计算过程中不会导致对 0 求对数情况的出现。
当 `log_input` 设置为 `False` 时,损失函数的数学计算公式为:

.. math::
Expand All @@ -33,7 +33,7 @@ PoissonNLLLoss
:::::::::
- **log_input** (bool,可选) - 输入是否为对数函数映射后结果,默认值为 ``True``。
- **full** (bool,可选) - 是否在损失计算中包括 Stirling 近似项。默认值为 ``False``。
- **eps** (float,可选) - 在 :attr:`log_input` 为 ``True`` 时使用的常数小量。默认值为 1e-8。
- **epsilon** (float,可选) - 在 :attr:`log_input` 为 ``True`` 时使用的常数小量。默认值为 1e-8。
- **reduction** (str,可选) - 指定应用于输出结果的计算方式,可选值有 ``none``、``mean`` 和 ``sum``。默认为 ``mean``,计算 ``mini-batch`` loss 均值。设置为 ``sum`` 时,计算 ``mini-batch`` loss 的总和。设置为 ``none`` 时,则返回 loss Tensor。默认值下为 ``mean``。
- **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name` ,一般无需设置,默认值为 None。

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ torch.nn.PoissonNLLLoss(log_input=True, full=False, size_average=None, eps=1e-08
### [paddle.nn.PoissonNLLLoss](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/nn/PoissonNLLLoss_cn.html)

```python
paddle.nn.PoissonNLLLoss(log_input=True, full=False, eps=1e-8, reduction='mean', name=None)
paddle.nn.PoissonNLLLoss(log_input=True, full=False, epsilon=1e-8, reduction='mean', name=None)
```

Pytorch 相比 Paddle 支持更多其他参数,具体如下:
Expand All @@ -21,7 +21,7 @@ Pytorch 相比 Paddle 支持更多其他参数,具体如下:
| log_input | log_input | 输入是否为对数函数映射后结果。 |
| full | full | 是否在损失计算中包括 Stirling 近似项。 |
| size_average | - | 已废弃(可用 `reduction` 代替)。表示是否采用 batch 中各样本 loss 平均值作为最终的 loss。如果置 False,则采用加和作为 loss。默认为 True,paddle 需要转写。 |
| eps | eps | 在 `log_input` 为 True 时使用的常数小量。默认值为 1e-8。 |
| eps | epsilon | 在 `log_input` 为 True 时使用的常数小量。默认值为 1e-8,仅参数名不一致。 |
| reduce | - | 已废弃(可用 `reduction` 代替)。表示是否采用输出单个值作为 loss。如果置 False,则每个元素输出一个 loss 并忽略 `size_average`。默认为 True,paddle 需要转写。 |
| reduction | reduction | 指定应用于输出结果的计算方式,可选值有 `none`、`mean` 和 `sum`。默认为 `mean`,计算 mini-batch loss 均值。设置为 `sum` 时,计算 mini-batch loss 的总和。设置为 `none` 时,则返回 loss Tensor。默认值下为 `mean`。两者完全一致。 |

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Pytorch 相比 Paddle 支持更多其他参数,具体如下:
| size_average | - | PyTorch 已弃用, Paddle 无此参数,需要转写。 |
| reduce | - | PyTorch 已弃用, Paddle 无此参数,需要转写。 |
| reduction | reduction | 表示应用于输出结果的计算方式。 |
| beta | delta | SmoothL1Loss 损失的阈值参数。 |
| beta | delta | SmoothL1Loss 损失的阈值参数,beta 不为 1.0 时 Paddle 不支持,暂无转写方式。 |

### 转写示例
#### size_average
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,3 @@ torch.broadcast_tensors(x, y)
# Paddle 写法
paddle.broadcast_tensors([x, y])
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
## [仅参数名不一致]torch.finfo

### [torch.finfo](https://pytorch.org/docs/stable/type_info.html#torch-finfo)

```python
torch.finfo(type)
```

### [paddle.finfo](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/finfo_cn.html)

```python
paddle.finfo(dtype)
```

两者功能一致,参数名不一致,具体如下:

### 参数映射

| PyTorch | PaddlePaddle | 备注 |
| ------- | ------------ | -------------------------------- |
| type | dtype | 输入的数据类型,仅参数名不一致。 |
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
## [参数完全一致]torch.iinfo

### [torch.iinfo](https://pytorch.org/docs/stable/type_info.html#torch-iinfo)

```python
torch.iinfo(type)
```

### [paddle.iinfo](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/iinfo_cn.html)

```python
paddle.iinfo(dtype)
```

paddle 参数和 torch 参数完全一致,具体如下:

### 参数映射

| PyTorch | PaddlePaddle | 备注 |
| ------- | ------------ | -------------------------------- |
| type | dtype | 输入的数据类型,仅参数名不一致。 |
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@
| 328 | [torch.get_default_dtype](https://pytorch.org/docs/stable/generated/torch.get_default_dtype.html#torch-get-default-dtype) |[paddle.get_default_dtype](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/get_default_dtype_cn.html#get-default-dtype)| 无参数 , [差异对比](https://github.com/PaddlePaddle/docs/tree/develop/docs/guides/model_convert/convert_from_pytorch/api_difference/others/torch.get_default_dtype.md)|
| 329 | [torch.is_grad_enabled](https://pytorch.org/docs/stable/generated/torch.is_grad_enabled.html?highlight=torch+is_grad_enabled#torch.is_grad_enabled) |[paddle.is_grad_enabled](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/is_grad_enabled_cn.html#is-grad-enabled)|无参数, [差异对比](https://github.com/PaddlePaddle/docs/tree/develop/docs/guides/model_convert/convert_from_pytorch/api_difference/others/torch.is_grad_enabled.md)|
| 330 | [torch.manual_seed](https://pytorch.org/docs/stable/generated/torch.manual_seed.html#torch-manual-seed) |[paddle.seed](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/seed_cn.html)| 参数完全一致 , [差异对比](https://github.com/PaddlePaddle/docs/tree/develop/docs/guides/model_convert/convert_from_pytorch/api_difference/others/torch.manual_seed.md)|
| 331 | [torch.can_cast](https://pytorch.org/docs/stable/generated/torch.can_cast.html#torch-can-cast) | | 功能缺失 |

***持续更新...***

Expand Down Expand Up @@ -512,6 +513,7 @@
| 135 |[torch.nn.TransformerEncoderLayer](https://pytorch.org/docs/stable/generated/torch.nn.TransformerEncoderLayer.html#torch.nn.TransformerEncoderLayer)|[paddle.nn.TransformerEncoderLayer](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/nn/TransformerEncoderLayer_cn.html)|torch 参数更多, [差异对比](https://github.com/PaddlePaddle/docs/tree/develop/docs/guides/model_convert/convert_from_pytorch/api_difference/nn/torch.nn.TransformerEncoderLayer.md)|
| 136 |[torch.nn.TripletMarginLoss](https://pytorch.org/docs/stable/generated/torch.nn.TripletMarginLoss.html#torch.nn.TripletMarginLoss)|[paddle.nn.TripletMarginLoss](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/nn/TripletMarginLoss_cn.html)|torch 参数更多, [差异对比](https://github.com/PaddlePaddle/docs/tree/develop/docs/guides/model_convert/convert_from_pytorch/api_difference/nn/torch.nn.TripletMarginLoss.md)|
| 137 | [torch.nn.parameter.Parameter](https://pytorch.org/docs/stable/generated/torch.nn.parameter.Parameter.html?highlight=torch%20nn%20parameter#torch.nn.parameter.Parameter) | [paddle.create_parameter](https://github.com/PaddlePaddle/Paddle/blob/release/2.1/python/paddle/fluid/layers/tensor.py#L77) | 功能一致, 参数不一致 , [差异对比](https://github.com/PaddlePaddle/docs/tree/develop/docs/guides/model_convert/convert_from_pytorch/api_difference/utils/torch.nn.parameter.Parameter.md) |
| 138 | [torch.nn.MultiLabelMarginLoss](https://pytorch.org/docs/stable/generated/torch.nn.MultiLabelMarginLoss) | | 功能缺失 |


***持续更新...***
Expand Down Expand Up @@ -607,6 +609,7 @@
|84|[torch.nn.functional.threshold](https://pytorch.org/docs/stable/generated/torch.nn.functional.threshold.html#torch.nn.functional.threshold)|[paddle.nn.functional.thresholded_relu](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/nn/functional/thresholded_relu_cn.html)|torch 参数更多, [差异对比](https://github.com/PaddlePaddle/docs/tree/develop/docs/guides/model_convert/convert_from_pytorch/api_difference/functional/torch.nn.functional.threshold.md)|
|85|[torch.nn.functional.unfold](https://pytorch.org/docs/stable/generated/torch.nn.functional.unfold.html#torch.nn.functional.unfold)|[paddle.nn.functional.unfold](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/nn/functional/unfold_cn.html)|参数名不一致, [差异对比](https://github.com/PaddlePaddle/docs/tree/develop/docs/guides/model_convert/convert_from_pytorch/api_difference/functional/torch.nn.functional.unfold.md)|
|86|[torch.nn.functional.upsample_bilinear](https://pytorch.org/docs/stable/generated/torch.nn.functional.upsample_bilinear.html#torch.nn.functional.upsample_bilinear)|[paddle.nn.functional.upsample](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/nn/functional/upsample_cn.html#upsample)| 仅 paddle 参数更多 , [差异对比](https://github.com/PaddlePaddle/docs/tree/develop/docs/guides/model_convert/convert_from_pytorch/api_difference/functional/torch.nn.functional.upsample_bilinear.md)|
|87| (torch.nn.functional.multilabel_margin_loss)[https://pytorch.org/docs/stable/generated/torch.nn.functional.multilabel_margin_loss.html#torch.nn.functional.multilabel_margin_loss] | | 功能缺失 |

***持续更新...***

Expand Down