diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/nn/torch.nn.Module.get_buffer.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/nn/torch.nn.Module.get_buffer.md new file mode 100644 index 00000000000..0ee107d69ba --- /dev/null +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/nn/torch.nn.Module.get_buffer.md @@ -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") +``` diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/nn/torch.nn.Module.get_parameter.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/nn/torch.nn.Module.get_parameter.md new file mode 100644 index 00000000000..61afd8e883f --- /dev/null +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/nn/torch.nn.Module.get_parameter.md @@ -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") +``` diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/nn/torch.nn.Module.get_submodule.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/nn/torch.nn.Module.get_submodule.md new file mode 100644 index 00000000000..ff379fae01a --- /dev/null +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/nn/torch.nn.Module.get_submodule.md @@ -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") +``` diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/nn/torch.nn.Module.register_parameter.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/nn/torch.nn.Module.register_parameter.md new file mode 100644 index 00000000000..3b4bee98567 --- /dev/null +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/nn/torch.nn.Module.register_parameter.md @@ -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 实例,仅参数名不一致。 |