From 540cfee9589fbc4c115b1400e350726b8969d893 Mon Sep 17 00:00:00 2001 From: Micalling <2687920886@qq.com> Date: Tue, 17 Sep 2024 16:26:02 +0800 Subject: [PATCH 1/7] =?UTF-8?q?=E3=80=90Hackathon=207th=20No.23=E3=80=91NO?= =?UTF-8?q?.23=20=E4=B8=BA=20Paddle=20=E6=96=B0=E5=A2=9E=20ParameterDict?= =?UTF-8?q?=20API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/api/paddle/nn/ParameterDict_cn.rst | 25 +++++++++++++++++++ .../nn/torch.nn.ParameterDict.md | 21 ++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 docs/api/paddle/nn/ParameterDict_cn.rst create mode 100644 docs/guides/model_convert/convert_from_pytorch/api_difference/nn/torch.nn.ParameterDict.md diff --git a/docs/api/paddle/nn/ParameterDict_cn.rst b/docs/api/paddle/nn/ParameterDict_cn.rst new file mode 100644 index 00000000000..4f9c02ad70f --- /dev/null +++ b/docs/api/paddle/nn/ParameterDict_cn.rst @@ -0,0 +1,25 @@ +.. _cn_api_paddle_nn_ParameterDict: + +ParameterDict +------------------------------- + +.. py:class:: paddle.nn.ParameterDict(parameters=None) + + + + +参数字典容器。此容器的行为类似于 Python 字典,但它包含的参数将被正确地注册和添加。 + +参数 +:::::::::::: + + - **parameters** (iterable,可选) - 可迭代的 Parameters。 + +返回 +:::::::::::: +无 + +代码示例 +:::::::::::: + +COPY-FROM: paddle.nn.ParameterDict diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/nn/torch.nn.ParameterDict.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/nn/torch.nn.ParameterDict.md new file mode 100644 index 00000000000..11962914277 --- /dev/null +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/nn/torch.nn.ParameterDict.md @@ -0,0 +1,21 @@ +## [ 仅参数名不一致 ]torch.nn.ParameterDict + +### [torch.nn.ParameterDict](https://pytorch.org/docs/stable/generated/torch.nn.ParameterList.html?highlight=nn+parameterlist#torch.nn.ParameterDict) + +```python +torch.nn.ParameterDict(values=None) +``` + +### [paddle.nn.ParameterDict](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/nn/ParameterDict_cn.html#parameterdict) + +```python +paddle.nn.ParameterDict(parameters=None) +``` + +两者功能一致且参数用法一致,仅参数名不一致,具体如下: + +### 参数映射 + +| PyTorch | PaddlePaddle | 备注 | +| ------- | ------------ | ----------------------------------- | +| values | parameters | 可迭代的 Parameters,参数名不一致。 | From 1fd03872108f16afcd3c7a2bb0d7357ccb22b8dd Mon Sep 17 00:00:00 2001 From: Micalling <2687920886@qq.com> Date: Mon, 23 Sep 2024 13:18:27 +0800 Subject: [PATCH 2/7] update --- docs/api/paddle/nn/ParameterDict_cn.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/api/paddle/nn/ParameterDict_cn.rst b/docs/api/paddle/nn/ParameterDict_cn.rst index 4f9c02ad70f..60899966000 100644 --- a/docs/api/paddle/nn/ParameterDict_cn.rst +++ b/docs/api/paddle/nn/ParameterDict_cn.rst @@ -13,7 +13,7 @@ ParameterDict 参数 :::::::::::: - - **parameters** (iterable,可选) - 可迭代的 Parameters。 + - **parameters** (ParameterDict|OrderedDict|list[(key, Tensor)],可选) - 可迭代的 Parameters。 返回 :::::::::::: From f26c0ab248d6496770b3cc847c2c19f3532bce5e Mon Sep 17 00:00:00 2001 From: Micalling <2687920886@qq.com> Date: Fri, 11 Oct 2024 12:22:35 +0800 Subject: [PATCH 3/7] update --- docs/api/paddle/nn/ParameterDict_cn.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/api/paddle/nn/ParameterDict_cn.rst b/docs/api/paddle/nn/ParameterDict_cn.rst index 60899966000..2605a63d1c9 100644 --- a/docs/api/paddle/nn/ParameterDict_cn.rst +++ b/docs/api/paddle/nn/ParameterDict_cn.rst @@ -13,7 +13,7 @@ ParameterDict 参数 :::::::::::: - - **parameters** (ParameterDict|OrderedDict|list[(key, Tensor)],可选) - 可迭代的 Parameters。 + - **parameters** (ParameterDict | Mapping[str, Tensor] | Sequence[tuple[str, Tensor]],可选) - 可迭代的 Parameters。 返回 :::::::::::: From 5fa7d8592bf66b71678ed1846c8fe381dc01a5b8 Mon Sep 17 00:00:00 2001 From: Micalling <2687920886@qq.com> Date: Fri, 11 Oct 2024 16:42:48 +0800 Subject: [PATCH 4/7] update --- docs/api/paddle/nn/ParameterDict_cn.rst | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/docs/api/paddle/nn/ParameterDict_cn.rst b/docs/api/paddle/nn/ParameterDict_cn.rst index 2605a63d1c9..434aeec7f2b 100644 --- a/docs/api/paddle/nn/ParameterDict_cn.rst +++ b/docs/api/paddle/nn/ParameterDict_cn.rst @@ -11,15 +11,14 @@ ParameterDict 参数字典容器。此容器的行为类似于 Python 字典,但它包含的参数将被正确地注册和添加。 参数 -:::::::::::: +::::::::: - **parameters** (ParameterDict | Mapping[str, Tensor] | Sequence[tuple[str, Tensor]],可选) - 可迭代的 Parameters。 返回 -:::::::::::: +::::::::: 无 代码示例 -:::::::::::: - +::::::::: COPY-FROM: paddle.nn.ParameterDict From 82d07cc7c6e2b160533e51aea22c6b60f9f6b45e Mon Sep 17 00:00:00 2001 From: Micalling <2687920886@qq.com> Date: Fri, 11 Oct 2024 17:17:04 +0800 Subject: [PATCH 5/7] update --- docs/api/paddle/nn/Overview_cn.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/api/paddle/nn/Overview_cn.rst b/docs/api/paddle/nn/Overview_cn.rst index ee40272f162..f8927abff6a 100644 --- a/docs/api/paddle/nn/Overview_cn.rst +++ b/docs/api/paddle/nn/Overview_cn.rst @@ -49,6 +49,7 @@ paddle.nn 目录下包含飞桨框架支持的神经网络层和相关函数的 " :ref:`paddle.nn.Layer ` ", "基于 OOD 实现的动态图 Layer" " :ref:`paddle.nn.LayerList ` ", "用于保存子层列表" " :ref:`paddle.nn.ParameterList ` ", "参数列表容器" + " :ref:`paddle.nn.ParameterDict ` ", "参数字典容器" " :ref:`paddle.nn.Sequential ` ", "顺序容器;子 Layer 将按构造函数参数的顺序添加到此容器中" " :ref:`paddle.nn.LayerDict ` ", "保存子层到有序字典中,它包含的子层将被正确地注册和添加" From a2c3ae9803844da47b193e3da489bce03eace56f Mon Sep 17 00:00:00 2001 From: Micalling <2687920886@qq.com> Date: Sat, 12 Oct 2024 23:36:20 +0800 Subject: [PATCH 6/7] update --- .../api_difference/nn/torch.nn.ParameterDict.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/nn/torch.nn.ParameterDict.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/nn/torch.nn.ParameterDict.md index 11962914277..763624ea887 100644 --- a/docs/guides/model_convert/convert_from_pytorch/api_difference/nn/torch.nn.ParameterDict.md +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/nn/torch.nn.ParameterDict.md @@ -16,6 +16,7 @@ paddle.nn.ParameterDict(parameters=None) ### 参数映射 -| PyTorch | PaddlePaddle | 备注 | -| ------- | ------------ | ----------------------------------- | -| values | parameters | 可迭代的 Parameters,参数名不一致。 | + +| PyTorch | PaddlePaddle | 备注 | +| ------- | ------------ | ------------------------------------- | +| values | parameters | 可迭代的 Parameters,仅参数名不一致。 | From 344146059e7ae959cdbe573f673b95bc6a7338ce Mon Sep 17 00:00:00 2001 From: zachary sun <70642955+sunzhongkai588@users.noreply.github.com> Date: Tue, 15 Oct 2024 17:15:04 +0800 Subject: [PATCH 7/7] Update docs/api/paddle/nn/ParameterDict_cn.rst --- docs/api/paddle/nn/ParameterDict_cn.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/api/paddle/nn/ParameterDict_cn.rst b/docs/api/paddle/nn/ParameterDict_cn.rst index 434aeec7f2b..47dc38f471d 100644 --- a/docs/api/paddle/nn/ParameterDict_cn.rst +++ b/docs/api/paddle/nn/ParameterDict_cn.rst @@ -13,7 +13,7 @@ ParameterDict 参数 ::::::::: - - **parameters** (ParameterDict | Mapping[str, Tensor] | Sequence[tuple[str, Tensor]],可选) - 可迭代的 Parameters。 + - **parameters** (ParameterDict | Mapping[str, Tensor] | Sequence[tuple[str, Tensor]],可选) - 可迭代的 Parameters,默认值为 None。 返回 :::::::::