-
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.
* Add api_difference docs * Fix
- Loading branch information
Showing
42 changed files
with
1,338 additions
and
0 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
...es/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.add.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,34 @@ | ||
## [torch 参数更多]torch.Tensor.add | ||
|
||
### [torch.Tensor.add](https://pytorch.org/docs/1.13/generated/torch.Tensor.add.html#torch.Tensor.add) | ||
|
||
```python | ||
torch.Tensor.add(other, *, alpha=1) | ||
``` | ||
|
||
### [paddle.Tensor.add](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/Tensor_cn.html#add-y-name-none) | ||
|
||
```python | ||
paddle.Tensor.add(y, name=None) | ||
``` | ||
|
||
其中 PyTorch 相比 Paddle 支持更多其他参数,具体如下: | ||
|
||
### 参数映射 | ||
|
||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------- | ------------ | -------------------------------------------------------- | | ||
| other | y | 输入的 Tensor,仅参数名不一致。 | | ||
| alpha | - | 表示 other 的乘数,PaddlePaddle 无此参数,需要进行转写。 | | ||
|
||
### 转写示例 | ||
|
||
#### alpha:other 的乘数 | ||
|
||
```python | ||
# Pytorch 写法 | ||
y = torch.tensor([3, 5]).add(torch.tensor([2, 3]), alpha=2) | ||
|
||
# Paddle 写法 | ||
y = paddle.to_tensor([3, 5]).add(2 * paddle.to_tensor([2, 3])) | ||
``` |
34 changes: 34 additions & 0 deletions
34
...s/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.add_.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,34 @@ | ||
## [torch 参数更多]torch.Tensor.add\_ | ||
|
||
### [torch.Tensor.add\_](https://pytorch.org/docs/1.13/generated/torch.Tensor.add_.html#torch.Tensor.add_) | ||
|
||
```python | ||
torch.Tensor.add_(other, *, alpha=1) | ||
``` | ||
|
||
### [paddle.Tensor.add\_](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/Tensor_cn.html#id3) | ||
|
||
```python | ||
paddle.Tensor.add_(y, name=None) | ||
``` | ||
|
||
其中 PyTorch 相比 Paddle 支持更多其他参数,具体如下: | ||
|
||
### 参数映射 | ||
|
||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------- | ------------ | -------------------------------------------------------- | | ||
| other | y | 输入的 Tensor,仅参数名不一致。 | | ||
| alpha | - | 表示 other 的乘数,PaddlePaddle 无此参数,需要进行转写。 | | ||
|
||
### 转写示例 | ||
|
||
#### alpha:other 的乘数 | ||
|
||
```python | ||
# Pytorch 写法 | ||
torch.tensor([3, 5]).add_(torch.tensor([2, 3]), alpha=2) | ||
|
||
# Paddle 写法 | ||
paddle.to_tensor([3, 5]).add_(2 * paddle.to_tensor([2, 3])) | ||
``` |
22 changes: 22 additions & 0 deletions
22
...convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.exponential_.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,22 @@ | ||
## [torch 参数更多]torch.Tensor.exponential\_ | ||
|
||
### [torch.Tensor.exponential\_](https://pytorch.org/docs/1.13/generated/torch.Tensor.exponential_.html#torch.Tensor.exponential_) | ||
|
||
```python | ||
torch.Tensor.exponential_(lambd=1, *, generator=None) | ||
``` | ||
|
||
### [paddle.Tensor.exponential\_](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/Tensor_cn.html#exponential-lam-1-0-name-none) | ||
|
||
```python | ||
paddle.Tensor.exponential_(lam=1.0, name=None) | ||
``` | ||
|
||
其中 PyTorch 相比 Paddle 支持更多其他参数,具体如下: | ||
|
||
### 参数映射 | ||
|
||
| PyTorch | PaddlePaddle | 备注 | | ||
| --------- | ------------ | ----------------------------------------------------------------------------------- | | ||
| lambd | lam | 指数分布的 λ 参数,仅参数名不一致。 | | ||
| generator | - | 用于采样的伪随机数生成器,Paddle 无此参数,一般对网络训练结果影响不大,可直接删除。 | |
34 changes: 34 additions & 0 deletions
34
...s/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.half.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,34 @@ | ||
## [torch 参数更多]torch.Tensor.half | ||
|
||
### [torch.Tensor.half](https://pytorch.org/docs/1.13/generated/torch.Tensor.half.html#torch.Tensor.half) | ||
|
||
```python | ||
torch.Tensor.half(memory_format=torch.preserve_format) | ||
``` | ||
|
||
### [paddle.Tensor.astype](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/Tensor_cn.html#astype-dtype) | ||
|
||
```python | ||
paddle.Tensor.astype('float16') | ||
``` | ||
|
||
其中 PyTorch 相比 Paddle 支持更多其他参数,具体如下: | ||
|
||
### 参数映射 | ||
|
||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------------- | ------------ | ----------------------------------------------------------------------- | | ||
| memory_format | - | 表示内存格式,Paddle 无此参数,一般对网络训练结果影响不大,可直接删除。 | | ||
| - | dtype | 转换数据类型,PyTorch 无此参数,Paddle 设置为 paddle.float16。 | | ||
|
||
### 转写示例 | ||
|
||
#### dtype 参数:转换数据类型 | ||
|
||
```python | ||
# PyTorch 写法: | ||
y = x.half() | ||
|
||
# Paddle 写法: | ||
y = x.astype(paddle.float16) | ||
``` |
34 changes: 34 additions & 0 deletions
34
...s/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.long.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,34 @@ | ||
## [torch 参数更多]torch.Tensor.long | ||
|
||
### [torch.Tensor.long](https://pytorch.org/docs/1.13/generated/torch.Tensor.long.html#torch.Tensor.long) | ||
|
||
```python | ||
torch.Tensor.long(memory_format=torch.preserve_format) | ||
``` | ||
|
||
### [paddle.Tensor.astype](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/Tensor_cn.html#astype-dtype) | ||
|
||
```python | ||
paddle.Tensor.astype('int64') | ||
``` | ||
|
||
其中 PyTorch 相比 Paddle 支持更多其他参数,具体如下: | ||
|
||
### 参数映射 | ||
|
||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------------- | ------------ | ----------------------------------------------------------------------- | | ||
| memory_format | - | 表示内存格式,Paddle 无此参数,一般对网络训练结果影响不大,可直接删除。 | | ||
| - | dtype | 转换数据类型,PyTorch 无此参数,Paddle 设置为 paddle.int64。 | | ||
|
||
### 转写示例 | ||
|
||
#### dtype 参数:转换数据类型 | ||
|
||
```python | ||
# PyTorch 写法: | ||
y = x.long() | ||
|
||
# Paddle 写法: | ||
y = x.astype(paddle.int64) | ||
``` |
23 changes: 23 additions & 0 deletions
23
..._convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.multinomial.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 @@ | ||
## [torch 参数更多]torch.Tensor.multinomial | ||
|
||
### [torch.Tensor.multinomial](https://pytorch.org/docs/1.13/generated/torch.Tensor.multinomial.html#torch.Tensor.multinomial) | ||
|
||
```python | ||
torch.Tensor.multinomial(num_samples, replacement=False, *, generator=None) | ||
``` | ||
|
||
### [paddle.multinomial](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/multinomial_cn.html) | ||
|
||
```python | ||
paddle.multinomial(x, num_samples=1, replacement=False, name=None) | ||
``` | ||
|
||
其中 PyTorch 相比 Paddle 支持更多其他参数,具体如下: | ||
|
||
### 参数映射 | ||
|
||
| PyTorch | PaddlePaddle | 备注 | | ||
| ----------- | ------------ | ----------------------------------------------------------------------------------- | | ||
| num_samples | num_samples | 采样的次数。 | | ||
| replacement | replacement | 是否是可放回的采样。 | | ||
| generator | - | 用于采样的伪随机数生成器,Paddle 无此参数,一般对网络训练结果影响不大,可直接删除。 | |
37 changes: 37 additions & 0 deletions
37
...s/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.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,37 @@ | ||
## [torch 参数更多]torch.Tensor.norm | ||
|
||
### [torch.Tensor.norm](https://pytorch.org/docs/1.13/generated/torch.Tensor.norm.html#torch.Tensor.norm) | ||
|
||
```python | ||
torch.Tensor.norm(p='fro', dim=None, keepdim=False, dtype=None) | ||
``` | ||
|
||
### [paddle.Tensor.norm](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/Tensor_cn.html#norm-p-fro-axis-none-keepdim-false-name-none) | ||
|
||
```python | ||
paddle.Tensor.norm(p='fro', axis=None, keepdim=False, name=None) | ||
``` | ||
|
||
其中 PyTorch 相比 Paddle 支持更多其他参数,具体如下: | ||
|
||
### 参数映射 | ||
|
||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------- | ------------ | --------------------------------------------- | | ||
| p | p | 范数(ord)的种类。 | | ||
| dim | axis | 使用范数计算的轴,仅参数名不一致。 | | ||
| keepdim | keepdim | 是否在输出的 Tensor 中保留和输入一样的维度。 | | ||
| dtype | - | 输出数据类型,Paddle 无此参数,需要进行转写。 | | ||
|
||
### 转写示例 | ||
|
||
#### dtype 参数:输出数据类型 | ||
|
||
```python | ||
# Pytorch 写法 | ||
x.norm(dim=-1, dtype=torch.float32) | ||
|
||
# Paddle 写法 | ||
y = x.astype('float32') | ||
y.norm(dim=-1) | ||
``` |
23 changes: 23 additions & 0 deletions
23
...vert/convert_from_pytorch/api_difference/functional/torch.nn.functional.celu.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 @@ | ||
## [torch 参数更多]torch.nn.functional.celu | ||
|
||
### [torch.nn.functional.celu](https://pytorch.org/docs/1.13/generated/torch.nn.functional.celu.html#torch.nn.functional.celu) | ||
|
||
```python | ||
torch.nn.functional.celu(input, alpha=1.0, inplace=False) | ||
``` | ||
|
||
### [paddle.nn.functional.celu](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/nn/functional/celu_cn.html) | ||
|
||
```python | ||
paddle.nn.functional.celu(x, alpha=1.0, name=None) | ||
``` | ||
|
||
其中 PyTorch 相比 Paddle 支持更多其他参数,具体如下: | ||
|
||
### 参数映射 | ||
|
||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------- | ------------ | --------------------------------------------------------------------------------------------------------------- | | ||
| input | x | 输入的 Tensor,仅参数名不一致。 | | ||
| alpha | alpha | alpha 参数。 | | ||
| inplace | - | 表示在不更改变量的内存地址的情况下,直接修改变量的值,Paddle 无此参数,一般对网络训练结果影响不大,可直接删除。 | |
44 changes: 44 additions & 0 deletions
44
..._pytorch/api_difference/functional/torch.nn.functional.cosine_embedding_loss.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,44 @@ | ||
## [torch 参数更多]torch.nn.functional.cosine_embedding_loss | ||
|
||
### [torch.nn.functional.cosine_embedding_loss](https://pytorch.org/docs/1.13/generated/torch.nn.functional.cosine_embedding_loss.html#torch.nn.functional.cosine_embedding_loss) | ||
|
||
```python | ||
torch.nn.functional.cosine_embedding_loss(input1, input2, target, margin=0, size_average=None, reduce=None, reduction='mean') | ||
``` | ||
|
||
### [paddle.nn.functional.cosine_embedding_loss](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/nn/functional/cosine_embedding_loss_cn.html) | ||
|
||
```python | ||
paddle.nn.functional.cosine_embedding_loss(input1, input2, label, margin=0, reduction='mean', name=None) | ||
``` | ||
|
||
其中 PyTorch 相比 Paddle 支持更多其他参数,具体如下: | ||
|
||
### 参数映射 | ||
|
||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------------ | ------------ | ---------------------------------------------- | | ||
| input1 | input1 | 输入的 Tensor。 | | ||
| input2 | input2 | 输入的 Tensor。 | | ||
| target | label | 标签,仅参数名不一致。 | | ||
| margin | margin | 可以设置的范围为[-1, 1]。 | | ||
| size_average | - | 已废弃,和 reduce 组合决定损失计算方式。 | | ||
| reduce | - | 已废弃,和 size_average 组合决定损失计算方式。 | | ||
| reduction | reduction | 指定应用于输出结果的计算方式。 | | ||
|
||
### 转写示例 | ||
|
||
```python | ||
# Pytorch 的 size_average、reduce 参数转为 Paddle 的 reduction 参数 | ||
if size_average is None: | ||
size_average = True | ||
if reduce is None: | ||
reduce = True | ||
|
||
if size_average and reduce: | ||
reduction = 'mean' | ||
elif reduce: | ||
reduction = 'sum' | ||
else: | ||
reduction = 'none' | ||
``` |
27 changes: 27 additions & 0 deletions
27
.../convert_from_pytorch/api_difference/functional/torch.nn.functional.ctc_loss.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,27 @@ | ||
## [torch 参数更多]torch.nn.functional.ctc_loss | ||
|
||
### [torch.nn.functional.ctc_loss](https://pytorch.org/docs/1.13/generated/torch.nn.functional.ctc_loss.html#torch.nn.functional.ctc_loss) | ||
|
||
```python | ||
torch.nn.functional.ctc_loss(log_probs, targets, input_lengths, target_lengths, blank=0, reduction='mean', zero_infinity=False) | ||
``` | ||
|
||
### [paddle.nn.functional.ctc_loss](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/nn/functional/ctc_loss_cn.html) | ||
|
||
```python | ||
paddle.nn.functional.ctc_loss(log_probs, labels, input_lengths, label_lengths, blank=0, reduction='mean') | ||
``` | ||
|
||
其中 PyTorch 相比 Paddle 支持更多其他参数,具体如下: | ||
|
||
### 参数映射 | ||
|
||
| PyTorch | PaddlePaddle | 备注 | | ||
| -------------- | ------------- | ------------------------------------------------------------------ | | ||
| log_probs | log_probs | 经过 padding 的概率序列。 | | ||
| targets | labels | 经过 padding 的标签序列,仅参数名不一致。 | | ||
| input_lengths | input_lengths | 表示输入 log_probs 数据中每个序列的长度。 | | ||
| target_lengths | label_lengths | 表示 label 中每个序列的长度,仅参数名不一致。 | | ||
| blank | blank | 空格标记的 ID 值。 | | ||
| reduction | reduction | 指定应用于输出结果的计算方式。 | | ||
| zero_infinity | - | 是否设置 infinity 及关联梯度 为 0,Paddle 无此参数,暂无转写方式。 | |
23 changes: 23 additions & 0 deletions
23
...nvert/convert_from_pytorch/api_difference/functional/torch.nn.functional.elu.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 @@ | ||
## [torch 参数更多]torch.nn.functional.elu | ||
|
||
### [torch.nn.functional.elu](https://pytorch.org/docs/1.13/generated/torch.nn.functional.elu.html#torch.nn.functional.elu) | ||
|
||
```python | ||
torch.nn.functional.elu(input, alpha=1.0, inplace=False) | ||
``` | ||
|
||
### [paddle.nn.functional.elu](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/nn/functional/elu_cn.html) | ||
|
||
```python | ||
paddle.nn.functional.elu(x, alpha=1.0, name=None) | ||
``` | ||
|
||
其中 PyTorch 相比 Paddle 支持更多其他参数,具体如下: | ||
|
||
### 参数映射 | ||
|
||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------- | ------------ | --------------------------------------------------------------------------------------------------------------- | | ||
| input | x | 输入的 Tensor,仅参数名不一致。 | | ||
| alpha | alpha | alpha 参数。 | | ||
| inplace | - | 表示在不更改变量的内存地址的情况下,直接修改变量的值,Paddle 无此参数,一般对网络训练结果影响不大,可直接删除。 | |
25 changes: 25 additions & 0 deletions
25
...rt_from_pytorch/api_difference/functional/torch.nn.functional.gumbel_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,25 @@ | ||
## [torch 参数更多]torch.nn.functional.gumbel_softmax | ||
|
||
### [torch.nn.functional.gumbel_softmax](https://pytorch.org/docs/1.13/generated/torch.nn.functional.gumbel_softmax.html#torch.nn.functional.gumbel_softmax) | ||
|
||
```python | ||
torch.nn.functional.gumbel_softmax(logits, tau=1, hard=False, eps=1e-10, dim=- 1) | ||
``` | ||
|
||
### [paddle.nn.functional.gumbel_softmax](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/nn/functional/gumbel_softmax_cn.html) | ||
|
||
```python | ||
paddle.nn.functional.gumbel_softmax(x, temperature=1.0, hard=False, axis=- 1, name=None) | ||
``` | ||
|
||
其中 PyTorch 相比 Paddle 支持更多其他参数,具体如下: | ||
|
||
### 参数映射 | ||
|
||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------- | ------------ | ------------------------------------------------------------------------------------------------- | | ||
| logits | x | 一个 N-D Tensor,前 N-1 维用于独立分布 batch 的索引,最后一维表示每个类别的概率,仅参数名不一致。 | | ||
| tau | temperature | 大于 0 的标量,仅参数名不一致。 | | ||
| hard | hard | 如果是 True,返回离散的 one-hot 向量。如果是 False,返回软样本。 | | ||
| eps | - | eps 参数,Paddle 无此参数,暂无转写方式。 | | ||
| dim | axis | 按照维度 axis 计算 softmax,仅参数名不一致。 | |
22 changes: 22 additions & 0 deletions
22
...convert_from_pytorch/api_difference/functional/torch.nn.functional.hardswish.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,22 @@ | ||
## [torch 参数更多]torch.nn.functional.hardswish | ||
|
||
### [torch.nn.functional.hardswish](https://pytorch.org/docs/1.13/generated/torch.nn.functional.hardswish.html#torch.nn.functional.hardswish) | ||
|
||
```python | ||
torch.nn.functional.hardswish(input, inplace=False) | ||
``` | ||
|
||
### [paddle.nn.functional.hardswish](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/nn/functional/hardswish_cn.html) | ||
|
||
```python | ||
paddle.nn.functional.hardswish(x, name=None) | ||
``` | ||
|
||
其中 PyTorch 相比 Paddle 支持更多其他参数,具体如下: | ||
|
||
### 参数映射 | ||
|
||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------- | ------------ | --------------------------------------------------------------------------------------------------------------- | | ||
| input | x | 输入的 Tensor,仅参数名不一致。 | | ||
| inplace | - | 表示在不更改变量的内存地址的情况下,直接修改变量的值,Paddle 无此参数,一般对网络训练结果影响不大,可直接删除。 | |
Oops, something went wrong.