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

映射文档 No.368/374/377 #6137

Merged
merged 1 commit into from
Aug 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,34 +1,21 @@
## [ torch 参数更多 ]torch.linalg.lu
## [ 组合替代实现 ]torch.linalg.lu
Copy link
Collaborator

@zhwesky2010 zhwesky2010 Aug 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个文档Bug确实隐藏挺深的,主要是两者名字都完全一致,不写代码测试很难发现


### [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 @@ -793,6 +793,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