-
Notifications
You must be signed in to change notification settings - Fork 765
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix incorrect mapping type from docs/#6512 * update 2 doc * fix paddle api url in torch.mean * update some docs * fix some bugs
- Loading branch information
1 parent
d06dd48
commit 02dfe80
Showing
20 changed files
with
494 additions
and
15 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
...es/model_convert/convert_from_pytorch/api_difference/Tensor/torch.BoolTensor.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,23 @@ | ||
## [ 仅 paddle 参数更多 ] torch.BoolTensor | ||
|
||
### [torch.BoolTensor](https://pytorch.org/docs/stable/tensors.html) | ||
|
||
```python | ||
torch.BoolTensor(data) | ||
``` | ||
|
||
### [paddle.to_tensor](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/to_tensor_cn.html#to-tensor) | ||
|
||
```python | ||
paddle.to_tensor(data, dtype='bool', place='cpu') | ||
``` | ||
|
||
Paddle 比 PyTorch 支持更多参数,具体如下: | ||
|
||
### 参数映射 | ||
|
||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------- | ------------ | ----------------------------------------------------------- | | ||
| data | data | 要转换的数据。 | | ||
| - | dtype | Tensor 的数据类型,PyTorch 无此参数,Paddle 需设置为 'bool'。 | | ||
| - | place | Tensor 的设备,PyTorch 无此参数,Paddle 需设置为 'cpu' 。 | |
23 changes: 23 additions & 0 deletions
23
...s/model_convert/convert_from_pytorch/api_difference/Tensor/torch.FloatTensor.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,23 @@ | ||
## [ 仅 paddle 参数更多 ] torch.FloatTensor | ||
|
||
### [torch.FloatTensor](https://pytorch.org/docs/stable/tensors.html) | ||
|
||
```python | ||
torch.FloatTensor(data) | ||
``` | ||
|
||
### [paddle.to_tensor](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/to_tensor_cn.html#to-tensor) | ||
|
||
```python | ||
paddle.to_tensor(data, dtype='float32', place='cpu') | ||
``` | ||
|
||
Paddle 比 PyTorch 支持更多参数,具体如下: | ||
|
||
### 参数映射 | ||
|
||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------- | ------------ | ----------------------------------------------------------- | | ||
| data | data | 要转换的数据。 | | ||
| - | dtype | Tensor 的数据类型,PyTorch 无此参数,Paddle 需设置为 'float32'。 | | ||
| - | place | Tensor 的设备,PyTorch 无此参数,Paddle 需设置为 'cpu' 。 | |
23 changes: 23 additions & 0 deletions
23
...des/model_convert/convert_from_pytorch/api_difference/Tensor/torch.IntTensor.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,23 @@ | ||
## [ 仅 paddle 参数更多 ] torch.IntTensor | ||
|
||
### [torch.IntTensor](https://pytorch.org/docs/stable/tensors.html) | ||
|
||
```python | ||
torch.IntTensor(data) | ||
``` | ||
|
||
### [paddle.to_tensor](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/to_tensor_cn.html#to-tensor) | ||
|
||
```python | ||
paddle.to_tensor(data, dtype='int32', place='cpu') | ||
``` | ||
|
||
Paddle 比 PyTorch 支持更多参数,具体如下: | ||
|
||
### 参数映射 | ||
|
||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------- | ------------ | ----------------------------------------------------------- | | ||
| data | data | 要转换的数据。 | | ||
| - | dtype | Tensor 的数据类型,PyTorch 无此参数,Paddle 需设置为 'int32'。 | | ||
| - | place | Tensor 的设备,PyTorch 无此参数,Paddle 需设置为 'cpu' 。 | |
23 changes: 23 additions & 0 deletions
23
...es/model_convert/convert_from_pytorch/api_difference/Tensor/torch.LongTensor.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,23 @@ | ||
## [ 仅 paddle 参数更多 ] torch.LongTensor | ||
|
||
### [torch.LongTensor](https://pytorch.org/docs/stable/tensors.html) | ||
|
||
```python | ||
torch.LongTensor(data) | ||
``` | ||
|
||
### [paddle.to_tensor](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/to_tensor_cn.html#to-tensor) | ||
|
||
```python | ||
paddle.to_tensor(data, dtype='int64', place='cpu') | ||
``` | ||
|
||
Paddle 比 PyTorch 支持更多参数,具体如下: | ||
|
||
### 参数映射 | ||
|
||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------- | ------------ | ----------------------------------------------------------- | | ||
| data | data | 要转换的数据。 | | ||
| - | dtype | Tensor 的数据类型,PyTorch 无此参数,Paddle 需设置为 'int64'。 | | ||
| - | place | Tensor 的设备,PyTorch 无此参数,Paddle 需设置为 'cpu' 。 | |
2 changes: 1 addition & 1 deletion
2
...convert_from_pytorch/api_difference/functional/torch.nn.functional.embedding.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
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
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
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
47 changes: 47 additions & 0 deletions
47
docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.norm.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,47 @@ | ||
## [ torch 参数更多 ]torch.norm | ||
|
||
### [torch.norm](https://pytorch.org/docs/stable/generated/torch.norm.html) | ||
|
||
```python | ||
torch.norm(input, p='fro', dim=None, keepdim=False, out=None, dtype=None) | ||
``` | ||
|
||
### [paddle.linalg.norm](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/linalg/norm_cn.html#norm) | ||
|
||
```python | ||
paddle.linalg.norm(x, p='fro', axis=None, keepdim=False, name=None) | ||
``` | ||
|
||
PyTorch 相比 Paddle 支持更多其他参数,具体如下: | ||
|
||
### 参数映射 | ||
|
||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------- | ------------ | -- | | ||
| input | x | 输入 Tensor,仅参数名不一致。 | | ||
| p | p | 范数(ord)的种类。 | | ||
| dim | axis | 使用范数计算的轴,仅参数名不一致。 | | ||
| keepdim | keepdim | 是否在输出的 Tensor 中保留和输入一样的维度。 | | ||
| out | - | 表示输出的 Tensor,Paddle 无此参数,需要转写。 | | ||
| dtype | - | 表示输出 Tensor 的数据类型, Paddle 无此参数,需要转写。 | | ||
|
||
### 转写示例 | ||
|
||
#### out 参数:指定输出 | ||
``` python | ||
# PyTorch 写法: | ||
torch.norm(x, out=y) | ||
|
||
# Paddle 写法: | ||
paddle.assign(paddle.linalg.norm(x) , y) | ||
``` | ||
|
||
#### dtype:表示输出 Tensor 的数据类型 | ||
|
||
```python | ||
# PyTorch 写法 | ||
torch.norm(x, dtype=torch.float64) | ||
|
||
# Paddle 写法 | ||
paddle.linalg.norm(x.astype(paddle.float64)) | ||
``` |
24 changes: 24 additions & 0 deletions
24
docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.rrelu.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,24 @@ | ||
## [ 仅参数默认值不一致 ]torch.rrelu | ||
|
||
### [torch.rrelu](https://pytorch.org/docs/stable/generated/torch.nn.functional.rrelu.html#torch.nn.functional.rrelu) | ||
|
||
```python | ||
torch.rrelu(input, lower=1./8, upper=1./3, training=False) | ||
``` | ||
|
||
### [paddle.nn.functional.rrelu](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/nn/functional/rrelu_cn.html) | ||
|
||
```python | ||
paddle.nn.functional.rrelu(x, lower=1./8, upper=1./3, training=True, name=None) | ||
``` | ||
|
||
其中 PyTorch 和 Paddle 功能一致,仅参数名与参数默认值不一致,具体如下: | ||
|
||
### 参数映射 | ||
|
||
| PyTorch | PaddlePaddle | 备注 | | ||
| -------- | ------------ | --------------------------------------------------------------------------------------------------------------- | | ||
| input | x | 输入的 Tensor,仅参数名不一致。 | | ||
| lower | lower | 负值斜率的随机值范围下限。 | | ||
| upper | upper | 负值斜率的随机值范围上限。 | | ||
| training | training | 标记是否为训练阶段,仅参数默认值不一致。 | |
23 changes: 23 additions & 0 deletions
23
docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.selu.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,23 @@ | ||
## [仅 paddle 参数更多]torch.selu | ||
|
||
### [torch.selu](https://pytorch.org/docs/stable/generated/torch.nn.functional.selu.html#torch.nn.functional.selu) | ||
|
||
```python | ||
torch.selu(input) | ||
``` | ||
|
||
### [paddle.nn.functional.selu](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/nn/functional/selu_cn.html) | ||
|
||
```python | ||
paddle.nn.functional.selu(x, scale=1.0507009873554804934193349852946, alpha=1.6732632423543772848170429916717, name=None) | ||
``` | ||
|
||
其中 Paddle 相比 PyTorch 支持更多其他参数,具体如下: | ||
|
||
### 参数映射 | ||
|
||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------- | ------------ | --------------------------------------------------------------------------------------------------------------- | | ||
| input | x | 输入的 Tensor,仅参数名不一致。 | | ||
| - | scale | selu 激活计算公式中的 scale 值,PyTorch 无此参数,Paddle 保持默认即可。 | | ||
| - | alpha | selu 激活计算公式中的 alpha 值,PyTorch 无此参数,Paddle 保持默认即可。 | |
33 changes: 33 additions & 0 deletions
33
...onvert/convert_from_pytorch/api_difference/ops/torch.set_default_tensor_type.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,33 @@ | ||
## [ 参数不一致 ]torch.set_default_tensor_type | ||
|
||
### [torch.set\_default\_tensor\_type](https://pytorch.org/docs/stable/generated/torch.set_default_tensor_type.html) | ||
|
||
```python | ||
torch.set_default_tensor_type(t) | ||
``` | ||
|
||
### [paddle.set\_default\_dtype](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/set_default_dtype_cn.html#set-default-dtype) | ||
|
||
```python | ||
paddle.set_default_dtype(d) | ||
``` | ||
|
||
其中 PyTorch 与 Paddle 的参数类型不一致,具体如下: | ||
|
||
### 参数映射 | ||
|
||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------- | ------------ | -- | | ||
| t | d | 指定的默认张量类型,参数类型不一致。PyTorch 支持张量类型或其名称字符串(如 `torch.FloatTensor`,Paddle 支持直接指定 `dtype`(如 `paddle.float32`),需要转写。 | | ||
|
||
### 转写示例 | ||
|
||
#### t 张量类型 | ||
|
||
```python | ||
# PyTorch | ||
torch.set_default_tensor_type(torch.FloatTensor) | ||
|
||
# Paddle | ||
paddle.set_default_dtype(paddle.float32) | ||
``` |
36 changes: 36 additions & 0 deletions
36
docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.softmax.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,36 @@ | ||
## [ torch 参数更多 ]torch.softmax | ||
|
||
### [torch.softmax](https://pytorch.org/docs/stable/generated/torch.softmax.html) | ||
|
||
```python | ||
torch.softmax(input, dim, *, dtype=None, out=None) | ||
``` | ||
|
||
### [paddle.nn.functional.softmax](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/nn/functional/softmax_cn.html#softmax) | ||
|
||
```python | ||
paddle.nn.functional.softmax(x, axis=-1, dtype=None, name=None) | ||
``` | ||
|
||
PyTorch 相比 Paddle 支持更多其他参数,具体如下: | ||
|
||
### 参数映射 | ||
|
||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------- | ------------ | -- | | ||
| input | x | 表示输入张量,仅参数名不一致。 | | ||
| dim | axis | 表示对输入 Tensor 进行运算的轴,仅参数名不一致。 | | ||
| dtype | dtype | 表示返回张量所需的数据类型。 | | ||
| out | - | 表示输出的 Tensor ,Paddle 无此参数,需要转写。 | | ||
|
||
### 转写示例 | ||
|
||
#### out | ||
|
||
```python | ||
# PyTorch | ||
torch.softmax(x, dim, out=y) | ||
|
||
# Paddle | ||
paddle.assign(paddle.nn.functional.softmax(x, dim), y) | ||
``` |
Oops, something went wrong.