forked from PaddlePaddle/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 映射文档 No. 59 * 映射文档 No. 59 * 映射文档 No. 59
- Loading branch information
1 parent
2b72c99
commit 6fab725
Showing
10 changed files
with
294 additions
and
2 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
...el_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.bernoulli.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 参数更多 ] torch.Tensor.bernoulli | ||
|
||
### [torch.Tensor.bernoulli](https://pytorch.org/docs/1.13/generated/torch.Tensor.bernoulli.html#torch.Tensor.bernoulli) | ||
|
||
```python | ||
torch.Tensor.bernoulli(*, generator=None) | ||
``` | ||
|
||
### [paddle.bernoulli](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/bernoulli_cn.html#bernoulli) | ||
|
||
```python | ||
paddle.bernoulli(x, name=None) | ||
``` | ||
|
||
其中 Pytorch 相比 Paddle 支持更多其他参数,具体如下: | ||
|
||
### 参数映射 | ||
|
||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------------- | ------------ | ----------------------------------------------------------------------------------- | | ||
| generator | - | 用于采样的伪随机数生成器, Paddle 无此参数,一般对网络训练结果影响不大,可直接删除。 | | ||
|
||
### 转写示例 | ||
|
||
```python | ||
# torch 写法 | ||
x = torch.tensor([0.2, 0.6, 0.8]) | ||
y = x.bernoulli() | ||
|
||
# paddle 写法 | ||
x = paddle.to_tensor([0.2, 0.6, 0.8]) | ||
y = paddle.bernoulli(x) | ||
``` |
33 changes: 33 additions & 0 deletions
33
...del_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.bfloat16.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 参数更多 ] torch.Tensor.bfloat16 | ||
|
||
### [torch.Tensor.bfloat16](https://pytorch.org/docs/1.13/generated/torch.Tensor.bfloat16.html#torch.Tensor.bfloat16) | ||
|
||
```python | ||
torch.Tensor.bfloat16(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('bfloat16') | ||
``` | ||
|
||
其中 Pytorch 相比 Paddle 支持更多其他参数,具体如下: | ||
|
||
### 参数映射 | ||
|
||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------------- | ------------ | ----------------------------------------------------------------------------------- | | ||
| memory_format | - | 表示内存格式, Paddle 无此参数,一般对网络训练结果影响不大,可直接删除。 | | ||
|
||
### 转写示例 | ||
|
||
```python | ||
# torch 写法 | ||
x = torch.randn(3, 3) | ||
y = x.bfloat16() | ||
|
||
# paddle 写法 | ||
x = paddle.randn([3, 3]) | ||
y = x.astype('bfloat16') | ||
``` |
33 changes: 33 additions & 0 deletions
33
...s/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.bool.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 参数更多 ] torch.Tensor.bool | ||
|
||
### [torch.Tensor.bool](https://pytorch.org/docs/1.13/generated/torch.Tensor.bool.html#torch.Tensor.bool) | ||
|
||
```python | ||
torch.Tensor.bool(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('bool') | ||
``` | ||
|
||
其中 Pytorch 相比 Paddle 支持更多其他参数,具体如下: | ||
|
||
### 参数映射 | ||
|
||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------------- | ------------ | ----------------------------------------------------------------------------------- | | ||
| memory_format | - | 表示内存格式, Paddle 无此参数,一般对网络训练结果影响不大,可直接删除。 | | ||
|
||
### 转写示例 | ||
|
||
```python | ||
# torch 写法 | ||
x = torch.tensor([-1, 0, 1]) | ||
y = x.bool() | ||
|
||
# paddle 写法 | ||
x = paddle.to_tensor([-1, 0, 1]) | ||
y = x.astype('bool') | ||
``` |
33 changes: 33 additions & 0 deletions
33
...s/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.byte.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 参数更多 ] torch.Tensor.byte | ||
|
||
### [torch.Tensor.byte](https://pytorch.org/docs/1.13/generated/torch.Tensor.byte.html#torch.Tensor.byte) | ||
|
||
```python | ||
torch.Tensor.byte(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('uint8') | ||
``` | ||
|
||
其中 Pytorch 相比 Paddle 支持更多其他参数,具体如下: | ||
|
||
### 参数映射 | ||
|
||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------------- | ------------ | ----------------------------------------------------------------------------------- | | ||
| memory_format | - | 表示内存格式, Paddle 无此参数,一般对网络训练结果影响不大,可直接删除。 | | ||
|
||
### 转写示例 | ||
|
||
```python | ||
# torch 写法 | ||
x = torch.tensor([0, 1, 2, 3]) | ||
y = x.byte() | ||
|
||
# paddle 写法 | ||
x = paddle.to_tensor([0, 1, 2, 3]) | ||
y = x.astype('uint8') | ||
``` |
31 changes: 31 additions & 0 deletions
31
...s/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.char.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,31 @@ | ||
## [ torch 参数更多 ] torch.Tensor.char | ||
|
||
### [torch.Tensor.char](https://pytorch.org/docs/1.13/generated/torch.Tensor.char.html#torch.Tensor.char) | ||
|
||
```python | ||
torch.Tensor.char(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('int8') | ||
``` | ||
|
||
其中 Pytorch 相比 Paddle 支持更多其他参数,具体如下: | ||
|
||
### 参数映射 | ||
|
||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------------- | ------------ | ----------------------------------------------------------------------------------- | | ||
| memory_format | - | 表示内存格式, Paddle 无此参数,一般对网络训练结果影响不大,可直接删除。 | | ||
|
||
### 转写示例 | ||
|
||
```python | ||
# torch 写法 | ||
x.char() | ||
|
||
# paddle 写法 | ||
x.astype('int8') | ||
``` |
21 changes: 21 additions & 0 deletions
21
.../model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.clone.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,21 @@ | ||
## [ torch 参数更多 ] torch.Tensor.clone | ||
|
||
### [torch.Tensor.clone](https://pytorch.org/docs/1.13/generated/torch.Tensor.clone.html#torch.Tensor.clone) | ||
|
||
```python | ||
torch.Tensor.clone(*, memory_format=torch.preserve_format) | ||
``` | ||
|
||
### [paddle.Tensor.clone](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/Tensor_cn.html#clone) | ||
|
||
```python | ||
paddle.Tensor.clone() | ||
``` | ||
|
||
其中 Pytorch 相比 Paddle 支持更多其他参数,具体如下: | ||
|
||
### 参数映射 | ||
|
||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------------- | ------------ | ----------------------------------------------------------------------------------- | | ||
| memory_format | - | 表示内存格式, Paddle 无此参数,一般对网络训练结果影响不大,可直接删除。 | |
5 changes: 3 additions & 2 deletions
5
.../model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.copy_.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
38 changes: 38 additions & 0 deletions
38
...es/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.div.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,38 @@ | ||
## [ torch 参数更多 ] torch.Tensor.div | ||
|
||
### [torch.Tensor.div](https://pytorch.org/docs/1.13/generated/torch.Tensor.div.html#torch.Tensor.div) | ||
|
||
```python | ||
torch.Tensor.div(other, *, rounding_mode=None) | ||
``` | ||
|
||
### [paddle.Tensor.divide](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/Tensor_cn.html#divide-y-name-none) | ||
|
||
```python | ||
paddle.Tensor.divide(y, name=None) | ||
``` | ||
|
||
其中 Pytorch 相比 Paddle 支持更多其他参数,具体如下: | ||
|
||
### 参数映射 | ||
|
||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------------- | ------------ | ----------------------------------------------------------------------------------- | | ||
| other | y | 表示输入的 Tensor ,仅参数名不一致。 | | ||
| rounding_mode | - | 用于指定在执行截断除法时的舍入模式,可选值为 'floor'(向下取整) 或 'trunc'(向零取整)。 Paddle 无此参数,需要进行转写。 | | ||
|
||
### 转写示例 | ||
|
||
```python | ||
# torch 写法 | ||
x = torch.tensor([4, 8, 12], dtype=torch.float32) | ||
y = torch.tensor([3, 4, 5], dtype=torch.float32) | ||
z1 = x.div(y, rounding_mode='floor') # 向下取整 | ||
z2 = x.div(y, rounding_mode='trunc') # 向零取整 | ||
|
||
# paddle 写法 | ||
x = paddle.to_tensor([4, 8, 12], dtype='float32') | ||
y = paddle.to_tensor([3, 4, 5], dtype='float32') | ||
z1 = x.divide(y).floor() # 向下取整 | ||
z2 = x.divide(y).trunc() # 向零取整 | ||
``` |
38 changes: 38 additions & 0 deletions
38
...model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.divide.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,38 @@ | ||
## [ torch 参数更多 ] torch.Tensor.divide | ||
|
||
### [torch.Tensor.divide](https://pytorch.org/docs/1.13/generated/torch.Tensor.divide.html#torch.Tensor.divide) | ||
|
||
```python | ||
torch.Tensor.divide(other, *, rounding_mode=None) | ||
``` | ||
|
||
### [paddle.Tensor.divide](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/Tensor_cn.html#divide-y-name-none) | ||
|
||
```python | ||
paddle.Tensor.divide(y, name=None) | ||
``` | ||
|
||
其中 Pytorch 相比 Paddle 支持更多其他参数,具体如下: | ||
|
||
### 参数映射 | ||
|
||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------------- | ------------ | ----------------------------------------------------------------------------------- | | ||
| other | y | 表示输入的 Tensor ,仅参数名不一致。 | | ||
| rounding_mode | - | 用于指定在执行截断除法时的舍入模式。可选值为 'floor'(向下取整) 或 'trunc'(向零取整)。 Paddle 无此参数,需要进行转写。 | | ||
|
||
### 转写示例 | ||
|
||
```python | ||
# torch 写法 | ||
x = torch.tensor([4, 8, 12], dtype=torch.float32) | ||
y = torch.tensor([3, 4, 5], dtype=torch.float32) | ||
z1 = x.divide(y, rounding_mode='floor') # 向下取整 | ||
z2 = x.divide(y, rounding_mode='trunc') # 向零取整 | ||
|
||
# paddle 写法 | ||
x = paddle.to_tensor([4, 8, 12], dtype='float32') | ||
y = paddle.to_tensor([3, 4, 5], dtype='float32') | ||
z1 = x.divide(y).floor() # 向下取整 | ||
z2 = x.divide(y).trunc() # 向零取整 | ||
``` |
31 changes: 31 additions & 0 deletions
31
...model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.double.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,31 @@ | ||
## [ torch 参数更多 ] torch.Tensor.double | ||
|
||
### [torch.Tensor.double](https://pytorch.org/docs/1.13/generated/torch.Tensor.double.html#torch-Tensor-double) | ||
|
||
```python | ||
torch.Tensor.double(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('float64') | ||
``` | ||
|
||
其中 Pytorch 相比 Paddle 支持更多其他参数,具体如下: | ||
|
||
### 参数映射 | ||
|
||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------------- | ------------ | ----------------------------------------------------------------------------------- | | ||
| memory_format | - | 表示内存格式, Paddle 无此参数,一般对网络训练结果影响不大,可直接删除。 | | ||
|
||
### 转写示例 | ||
|
||
```python | ||
# torch 写法 | ||
x.double() | ||
|
||
# paddle 写法 | ||
x.astype('float64') | ||
``` |