-
Notifications
You must be signed in to change notification settings - Fork 766
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
...el_convert/convert_from_pytorch/api_difference/nn/torch.nn.Module.get_buffer.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,19 @@ | ||
## [组合替代实现]torch.nn.Module.get_buffer | ||
|
||
### [torch.nn.Module.get_buffer](https://pytorch.org/docs/stable/generated/torch.nn.Module.html#torch.nn.Module.get_buffer) | ||
|
||
```python | ||
torch.nn.Module.get_buffer(target) | ||
``` | ||
|
||
Paddle 无此 API,需要组合实现。 | ||
|
||
### 转写示例 | ||
|
||
```python | ||
# Pytorch 写法 | ||
module.get_buffer("target") | ||
|
||
# Paddle 写法 | ||
getattr(module, "target") | ||
``` |
19 changes: 19 additions & 0 deletions
19
...convert/convert_from_pytorch/api_difference/nn/torch.nn.Module.get_parameter.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,19 @@ | ||
## [组合替代实现]torch.nn.Module.get_parameter | ||
|
||
### [torch.nn.Module.get_parameter](https://pytorch.org/docs/stable/generated/torch.nn.Module.html#torch.nn.Module.get_parameter) | ||
|
||
```python | ||
torch.nn.Module.get_parameter(target) | ||
``` | ||
|
||
Paddle 无此 API,需要组合实现。 | ||
|
||
### 转写示例 | ||
|
||
```python | ||
# Pytorch 写法 | ||
module.get_parameter("target") | ||
|
||
# Paddle 写法 | ||
getattr(module, "target") | ||
``` |
19 changes: 19 additions & 0 deletions
19
...convert/convert_from_pytorch/api_difference/nn/torch.nn.Module.get_submodule.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,19 @@ | ||
## [组合替代实现]torch.nn.Module.get_submodule | ||
|
||
### [torch.nn.Module.get_submodule](https://pytorch.org/docs/stable/generated/torch.nn.Module.html#torch.nn.Module.get_submodule) | ||
|
||
```python | ||
torch.nn.Module.get_submodule(target) | ||
``` | ||
|
||
Paddle 无此 API,需要组合实现。 | ||
|
||
### 转写示例 | ||
|
||
```python | ||
# Pytorch 写法 | ||
module.get_submodule("target") | ||
|
||
# Paddle 写法 | ||
getattr(module, "target") | ||
``` |
22 changes: 22 additions & 0 deletions
22
...rt/convert_from_pytorch/api_difference/nn/torch.nn.Module.register_parameter.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.nn.Module.register_parameter | ||
|
||
### [torch.nn.Module.register_parameter](https://pytorch.org/docs/stable/generated/torch.nn.Module.html#torch.nn.Module.register_parameter) | ||
|
||
```python | ||
torch.nn.Module.register_parameter(name, param) | ||
``` | ||
|
||
### [paddle.nn.Layer.add_parameter](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/nn/Layer_cn.html#add-parameter-name-parameter) | ||
|
||
```python | ||
paddle.nn.Layer.add_parameter(name, parameter) | ||
``` | ||
|
||
两者功能一致,仅参数名不一致,具体如下: | ||
|
||
### 参数映射 | ||
|
||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------- | ------------ | -------------------------------- | | ||
| name | name | 参数名。 | | ||
| param | parameter | Parameter 实例,仅参数名不一致。 | |