Skip to content

Commit

Permalink
Add diff doc (#6137)
Browse files Browse the repository at this point in the history
  • Loading branch information
co63oc authored Aug 28, 2023
1 parent 173e7a5 commit 7b22ad3
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 20 deletions.
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)
```
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 保持默认即可。 |
Original file line number Diff line number Diff line change
Expand Up @@ -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) | | 功能缺失 |


***持续更新...***
Expand Down

0 comments on commit 7b22ad3

Please sign in to comment.