-
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.
- Loading branch information
Showing
3 changed files
with
36 additions
and
20 deletions.
There are no files selected for viewing
27 changes: 7 additions & 20 deletions
27
...des/model_convert/convert_from_pytorch/api_difference/linalg/torch.linalg.lu.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 |
---|---|---|
@@ -1,34 +1,21 @@ | ||
## [ 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) | ||
|
||
```python | ||
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) | ||
``` |
28 changes: 28 additions & 0 deletions
28
...ides/model_convert/convert_from_pytorch/api_difference/nn/torch.nn.Dropout1d.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,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 保持默认即可。 | |
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