From 7b22ad30a68de3824c75a849b7c5030d917bd235 Mon Sep 17 00:00:00 2001 From: co63oc Date: Mon, 28 Aug 2023 17:01:42 +0800 Subject: [PATCH] Add diff doc (#6137) --- .../api_difference/linalg/torch.linalg.lu.md | 27 +++++------------- .../api_difference/nn/torch.nn.Dropout1d.md | 28 +++++++++++++++++++ .../pytorch_api_mapping_cn.md | 1 + 3 files changed, 36 insertions(+), 20 deletions(-) create mode 100644 docs/guides/model_convert/convert_from_pytorch/api_difference/nn/torch.nn.Dropout1d.md diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/linalg/torch.linalg.lu.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/linalg/torch.linalg.lu.md index 9df78ee2255..03c39e179cd 100644 --- a/docs/guides/model_convert/convert_from_pytorch/api_difference/linalg/torch.linalg.lu.md +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/linalg/torch.linalg.lu.md @@ -1,4 +1,4 @@ -## [ torch 参数更多 ]torch.linalg.lu +## [ 组合替代实现 ]torch.linalg.lu ### [torch.linalg.lu](https://pytorch.org/docs/stable/generated/torch.linalg.lu.html?highlight=torch+linalg+lu#torch.linalg.lu) @@ -6,29 +6,16 @@ torch.linalg.lu(A, *, pivot=True, out=None) ``` -### [paddle.linalg.lu](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/linalg/lu_cn.html) +Paddle 无此 API,需要组合实现。 +PyTorch 中 torch.linalg.lu 返回值为 (P, L, U),Paddle 中 paddle.linalg.lu 返回值为(LU, P),需要转写。 -```python -paddle.linalg.lu(x, pivot=True, get_infos=False, name=None) -``` - -Pytorch 相比 Paddle 支持更多其他参数,具体如下: - -### 参数映射 - -| PyTorch | PaddlePaddle | 备注 | -| ----------------------------------- | ------------ | ----------------------------------------------------------------------- | -| A | x | 表示需要进行 LU 分解的输入 Tensor ,仅参数名不一致。 | -| pivot | pivot | 表示 LU 分解时是否进行旋转。 | -| - | get_infos | 表示是否返回分解状态信息 , Paddle 保持默认即可。 | -| out | - | 表示输出的三个 Tensor 元组 , Paddle 无此参数,需要转写。 | +### 转写示例 -### 转写示例 -#### out:指定输出 ```python # Pytorch 写法 -torch.linalg.solve_triangular(A, out=(P, L, U)) +P, L, U = torch.linalg.lu(x) # Paddle 写法 -P, L, U = paddle.linalg.triangular_solve(A) +lu, p = paddle.linalg.lu(x) +P, L, U = paddle.linalg.lu_unpack(lu, p) ``` diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/nn/torch.nn.Dropout1d.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/nn/torch.nn.Dropout1d.md new file mode 100644 index 00000000000..b5941382bda --- /dev/null +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/nn/torch.nn.Dropout1d.md @@ -0,0 +1,28 @@ +## [ torch 参数更多 ]torch.nn.Dropout1d + +### [torch.nn.Dropout1d](https://pytorch.org/docs/stable/generated/torch.nn.Dropout1d.html#torch.nn.Dropout1d) + +```python +torch.nn.Dropout1d(p=0.5, + inplace=False) +``` + +### [paddle.nn.Dropout](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/nn/Dropout_cn.html#dropout) + +```python +paddle.nn.Dropout(p=0.5, + axis=None, + mode="upscale_in_train”, + name=None) +``` + +Pytorch 相比 Paddle 支持更多其他参数,具体如下: + +### 参数映射 + +| PyTorch | PaddlePaddle | 备注 | +| ------- | ------------ | --------------------------------------------------------------------------------------------------------------- | +| p | p | 表示丢弃概率。 | +| inplace | - | 表示在不更改变量的内存地址的情况下,直接修改变量的值,Paddle 无此参数,一般对网络训练结果影响不大,可直接删除。 | +| - | axis | 指定对输入 Tensor 进行 Dropout 操作的轴,PyTorch 无此参数,Paddle 保持默认即可。 | +| - | mode | 表示丢弃单元的方式,PyTorch 无此参数,Paddle 保持默认即可。 | diff --git a/docs/guides/model_convert/convert_from_pytorch/pytorch_api_mapping_cn.md b/docs/guides/model_convert/convert_from_pytorch/pytorch_api_mapping_cn.md index 91ce1af4cc5..bb039c5c0e6 100644 --- a/docs/guides/model_convert/convert_from_pytorch/pytorch_api_mapping_cn.md +++ b/docs/guides/model_convert/convert_from_pytorch/pytorch_api_mapping_cn.md @@ -802,6 +802,7 @@ | 6 | [torch.distributions.one_hot_categorical.OneHotCategorical](https://pytorch.org/docs/stable/distributions.html#torch.distributions.one_hot_categorical.OneHotCategorical) | | 功能缺失 | | 7 | [torch.distributions.transforms.CumulativeDistributionTransform](https://pytorch.org/docs/stable/distributions.html#torch.distributions.transforms.CumulativeDistributionTransform) | | 功能缺失 | | 8 | [torch.distributions.transforms.SoftplusTransform](https://pytorch.org/docs/stable/distributions.html#torch.distributions.transforms.SoftplusTransform) | | 功能缺失 | +| 9 | [torch.distributions.transforms.CatTransform](https://pytorch.org/docs/stable/distributions.html#torch.distributions.transforms.CatTransform) | | 功能缺失 | ***持续更新...***