diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.ormqr.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.ormqr.md index ce84ef5a8ef..eb273b50223 100644 --- a/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.ormqr.md +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.ormqr.md @@ -9,7 +9,7 @@ torch.Tensor.ormqr(input2, input3, left=True, transpose=False) ### [paddle.linalg.ormqr](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/linalg/ormqr_cn.html#ormqr) ```python -paddle.linalg.ormqr(x, tau, other, left=True, transpose=False) +paddle.linalg.ormqr(x, tau, y, left=True, transpose=False) ``` 两者功能一致且参数用法一致,仅参数名不一致,具体如下: @@ -19,6 +19,6 @@ paddle.linalg.ormqr(x, tau, other, left=True, transpose=False) | PyTorch | PaddlePaddle | 备注 | | --------- | ------------ | ---------------------------------- | | input2 | tau | Householder 反射系数,仅参数名不同 | -| input3 | other | 用于矩阵乘积,仅参数名不同 | +| input3 | y | 用于矩阵乘积,仅参数名不同 | | left | left | 决定了矩阵乘积运算的顺序,一致 | | transpose | transpose | 决定矩阵 Q 是否共轭转置变换,一致 | diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/distributed/torch.distributed.all_gather_object.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/distributed/torch.distributed.all_gather_object.md index f4cc179f813..a9d010e3772 100644 --- a/docs/guides/model_convert/convert_from_pytorch/api_difference/distributed/torch.distributed.all_gather_object.md +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/distributed/torch.distributed.all_gather_object.md @@ -1,4 +1,4 @@ -## [参数完全一致]torch.distributed.all_gather_object +## [ 输入参数用法不一致 ]torch.distributed.all_gather_object ### [torch.distributed.all_gather_object](https://pytorch.org/docs/stable/distributed.html?highlight=all_gather_object#torch.distributed.all_gather_object) @@ -18,13 +18,12 @@ paddle.distributed.all_gather_object(object_list, obj, group=None) | PyTorch | PaddlePaddle | 备注 | | -------- | ------------ | --------------------------------------------- | -| object_list | | 表示用于保存聚合结果的列表。需初始化成与 `group` 等长的列表 | -| | object_list | 表示用于保存聚合结果的列表。需初始化成空列表 | +| object_list | object_list | 表示用于保存聚合结果的列表。PyTorch 需初始化成与 `group` 等长的列表, Paddle 需初始化为空列表,需要转写。 | | obj | obj | 表示待聚合的对象。 | | group | group | 表示执行该操作的进程组实例。 | ### 转写示例 - +#### object_list:保存聚合结果列表 ```python # PyTorch 写法 import torch.distributed as dist diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/nn/torch.nn.GRU.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/nn/torch.nn.GRU.md index 69cc517c03a..0f80f94aab6 100644 --- a/docs/guides/model_convert/convert_from_pytorch/api_difference/nn/torch.nn.GRU.md +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/nn/torch.nn.GRU.md @@ -34,7 +34,7 @@ paddle.nn.GRU(input_size, | input_size | input_size | 表示输入 x 的大小。 | | hidden_size | hidden_size | 表示隐藏状态 h 大小。 | | num_layers | num_layers | 表示循环网络的层数。 | -| bias | bias_ih_attr, bias_hh_attr | 是否使用偏置, Paddle 支持自定义偏置属性, torch 不支持,需要转写。 | +| bias | bias_ih_attr, bias_hh_attr | 是否使用偏置, Paddle 的 bias_ih_attr, bias_hh_attr 参数均需与 PyTorch 设置一致,需要转写。 | | batch_first | time_major | PyTorch 表示 batch size 是否为第一维,PaddlePaddle 表示 time steps 是否为第一维,它们的意义相反。需要转写。 | | dropout | dropout | 表示 dropout 概率。 | | bidirectional | direction | PyTorch 表示是否进行双向 GRU,Paddle 使用字符串表示是双向 GRU(`bidirectional`)还是单向 GRU(`forward`)。 | diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/nn/torch.nn.GRUCell.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/nn/torch.nn.GRUCell.md index d056c6a2d66..2101ebf83d1 100644 --- a/docs/guides/model_convert/convert_from_pytorch/api_difference/nn/torch.nn.GRUCell.md +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/nn/torch.nn.GRUCell.md @@ -1,4 +1,4 @@ -## [ 输入参数用法不一致 ]torch.nn.GRUCell +## [ 返回参数类型不一致 ]torch.nn.GRUCell ### [torch.nn.GRUCell](https://pytorch.org/docs/stable/generated/torch.nn.GRUCell.html#torch.nn.GRUCell) ```python @@ -10,14 +10,14 @@ torch.nn.GRUCell(input_size, hidden_size, bias=True, device=None, dtype=None) paddle.nn.GRUCell(input_size, hidden_size, weight_ih_attr=None, weight_hh_attr=None, bias_ih_attr=None, bias_hh_attr=None, name=None) ``` -两者功能一致但参数不一,具体如下: +两者功能一致但输入参数用法不一致,且返回参数类型不同,具体如下: ### 参数映射 | PyTorch | PaddlePaddle | 备注 | | ------------- | ------------ | ------------------------------------------------------ | | input_size | input_size | 表示输入 x 的大小。 | | hidden_size | hidden_size | 表示隐藏状态 h 大小。 | -| bias | bias_ih_attr, bias_hh_attr | 是否使用偏置, Paddle 支持自定义偏置属性, torch 不支持,需要转写。 | +| bias | bias_ih_attr, bias_hh_attr | 是否使用偏置,Paddle 的 bias_ih_attr, bias_hh_attr 参数均需与 PyTorch 设置一致,需要转写。 | | device | - | 指定 Tensor 的设备,Paddle 无此参数,一般对网络训练结果影响不大,可直接删除。 | | dtype | - | Tensor 的所需数据类型,Paddle 无此参数,一般对网络训练结果影响不大,可直接删除。 | | - |weight_ih_attr| weight_ih 的参数, PyTorch 无此参数, Paddle 保持默认即可。 | @@ -28,15 +28,23 @@ paddle.nn.GRUCell(input_size, hidden_size, weight_ih_attr=None, weight_hh_attr=N #### bias:是否使用偏置 ```python # PyTorch 写法 -torch.nn.GRU(16, 32, bias=True) - +torch.nn.GRUCell(16, 32, bias=True) +# Paddle 写法 +paddle.nn.GRUCell(16, 32) +``` +```python +# PyTorch 写法 +torch.nn.GRUCell(16, 32, bias=False) # Paddle 写法 -paddle.nn.GRU(16, 32) +paddle.nn.GRUCell(16, 32, bias_ih_attr=False, bias_hh_attr=False) ``` +#### forward 类方法:前向传播 ```python # PyTorch 写法 -torch.nn.GRU(16, 32, bias=False) +rnn = torch.nn.GRUCell(2, 2) +result = rnn(inp, h0) # Paddle 写法 -paddle.nn.GRU(16, 32, bias_ih_attr=False, bias_hh_attr=False) +rnn = paddle.nn.GRUCell(2, 2) +result = rnn(inp, h0)[0] ``` diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/nn/torch.nn.LSTM.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/nn/torch.nn.LSTM.md index 014f18a2d19..4584fdf6908 100644 --- a/docs/guides/model_convert/convert_from_pytorch/api_difference/nn/torch.nn.LSTM.md +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/nn/torch.nn.LSTM.md @@ -39,7 +39,7 @@ paddle.nn.LSTM(input_size, | input_size | input_size | 表示输入 x 的大小。 | | hidden_size | hidden_size | 表示隐藏状态 h 大小。 | | num_layers | num_layers | 表示循环网络的层数。 | -| bias | bias_ih_attr, bias_hh_attr | 是否使用偏置, Paddle 支持自定义偏置属性, torch 不支持,需要转写。 | +| bias | bias_ih_attr, bias_hh_attr | 是否使用偏置, Paddle 的 bias_ih_attr, bias_hh_attr 参数均需与 PyTorch 设置一致,需要转写。 | | batch_first | time_major | PyTorch 表示 batch size 是否为第一维,PaddlePaddle 表示 time steps 是否为第一维,它们的意义相反。需要转写。 | | dropout | dropout | 表示 dropout 概率。 | | bidirectional | direction | PyTorch 表示是否进行双向,Paddle 使用字符串表示是双向 LSTM(`bidirectional`)还是单向 LSTM(`forward`)| diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/nn/torch.nn.LSTMCell.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/nn/torch.nn.LSTMCell.md index c1a675c98a4..54adb123931 100644 --- a/docs/guides/model_convert/convert_from_pytorch/api_difference/nn/torch.nn.LSTMCell.md +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/nn/torch.nn.LSTMCell.md @@ -1,4 +1,4 @@ -## [ 输入参数用法不一致 ]torch.nn.LSTMCell +## [ 返回参数类型不一致 ]torch.nn.LSTMCell ### [torch.nn.LSTMCell](https://pytorch.org/docs/stable/generated/torch.nn.LSTMCell.html#torch.nn.LSTMCell) ```python torch.nn.LSTMCell(input_size, hidden_size, bias=True, device=None, dtype=None) @@ -9,14 +9,14 @@ torch.nn.LSTMCell(input_size, hidden_size, bias=True, device=None, dtype=None) paddle.nn.LSTMCell(input_size, hidden_size, weight_ih_attr=None, weight_hh_attr=None, bias_ih_attr=None, bias_hh_attr=None, proj_size=0, name=None) ``` -两者功能一致但参数不一,具体如下: +两者功能一致但输入参数用法不一致,且返回参数类型不同,具体如下: ### 参数映射 | PyTorch | PaddlePaddle | 备注 | | ------------- | ------------ | ------------------------------------------------------ | | input_size | input_size | 表示输入 x 的大小。 | | hidden_size | hidden_size | 表示隐藏状态 h 大小。 | -| bias | bias_ih_attr, bias_hh_attr | 是否使用偏置, Paddle 支持自定义偏置属性, torch 不支持,需要转写。 | +| bias | bias_ih_attr, bias_hh_attr | 是否使用偏置, Paddle 的 bias_ih_attr, bias_hh_attr 参数均需与 PyTorch 设置一致,需要转写。 | | device | - | 指定 Tensor 的设备,Paddle 无此参数,一般对网络训练结果影响不大,可直接删除。 | | dtype | - | Tensor 的所需数据类型,一般对网络训练结果影响不大,可直接删除。 | | - |weight_ih_attr| weight_ih 的参数, PyTorch 无此参数, Paddle 保持默认即可。 | @@ -29,14 +29,21 @@ paddle.nn.LSTMCell(input_size, hidden_size, weight_ih_attr=None, weight_hh_attr= ```python # PyTorch 写法 torch.nn.LSTMCell(16, 32, bias=True) - # Paddle 写法 paddle.nn.LSTMCell(16, 32) ``` ```python # PyTorch 写法 torch.nn.LSTMCell(16, 32, bias=False) - # Paddle 写法 paddle.nn.LSTMCell(16, 32, bias_ih_attr=False, bias_hh_attr=False) ``` +#### forward 类方法:前向传播 +```python +# PyTorch 写法 +rnn = torch.nn.LSTMCell(2, 2) +result = rnn(inp, h0) + +# Paddle 写法 +rnn = paddle.nn.LSTMCell(2, 2) +result = rnn(inp, h0)[1] diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/nn/torch.nn.RNN.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/nn/torch.nn.RNN.md index aab6b8ea854..54095b40d53 100644 --- a/docs/guides/model_convert/convert_from_pytorch/api_difference/nn/torch.nn.RNN.md +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/nn/torch.nn.RNN.md @@ -27,7 +27,7 @@ paddle.nn.SimpleRNN(input_size, hidden_size, num_layers=1, activation='tanh', di | hidden_size | hidden_size | 表示隐藏状态 h 大小。 | | num_layers | num_layers | 表示循环网络的层数。 | | nonlinearity | activation | 表示激活函数类型,仅参数名不一致。 | -| bias | bias_ih_attr, bias_hh_attr | 是否使用偏置, Paddle 支持自定义偏置属性, torch 不支持,需要转写。 | +| bias | bias_ih_attr, bias_hh_attr | 是否使用偏置, Paddle 的 bias_ih_attr, bias_hh_attr 参数均需与 PyTorch 设置一致,需要转写。 | | batch_first | time_major | PyTorch 表示 batch size 是否为第一维,PaddlePaddle 表示 time steps 是否为第一维,它们的意义相反。需要转写。 | | dropout | dropout | 表示 dropout 概率。 | | bidirectional | direction | PyTorch 表示是否进行双向 RNN,Paddle 使用字符串表示是双向 RNN(`bidirectional`)还是单向 RNN(`forward`)。 | diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/nn/torch.nn.RNNBase.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/nn/torch.nn.RNNBase.md index 7b59964bec0..d4e45375bdf 100644 --- a/docs/guides/model_convert/convert_from_pytorch/api_difference/nn/torch.nn.RNNBase.md +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/nn/torch.nn.RNNBase.md @@ -24,7 +24,7 @@ paddle.nn.layer.rnn.RNNBase(mode, input_size, hidden_size, | input_size | input_size | 表示输入 x 的大小。 | | hidden_size | hidden_size | 表示隐藏状态 h 大小。 | | num_layers | num_layers | 表示循环网络的层数。 | -| bias | bias_ih_attr, bias_hh_attr | 是否使用偏置, Paddle 支持自定义偏置属性, torch 不支持,需要转写。 | +| bias | bias_ih_attr, bias_hh_attr | 是否使用偏置, Paddle 的 bias_ih_attr, bias_hh_attr 参数均需与 PyTorch 设置一致,需要转写。 | | batch_first | time_major | PyTorch 表示 batch size 是否为第一维,PaddlePaddle 表示 time steps 是否为第一维,它们的意义相反。需要转写。 | | dropout | dropout | 表示 dropout 概率。 | | bidirectional | direction | PyTorch 表示是否进行双向 RNN,Paddle 使用字符串表示是双向 RNN(`bidirectional`)还是单向 RNN(`forward`)。 | diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/nn/torch.nn.RNNCell.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/nn/torch.nn.RNNCell.md index 981a0f765fc..7aa872d7ff6 100644 --- a/docs/guides/model_convert/convert_from_pytorch/api_difference/nn/torch.nn.RNNCell.md +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/nn/torch.nn.RNNCell.md @@ -1,4 +1,4 @@ -## [ 输入参数用法不一致 ]torch.nn.RNNCell +## [ 返回参数类型不一致 ]torch.nn.RNNCell ### [torch.nn.RNNCell](https://pytorch.org/docs/stable/generated/torch.nn.RNNCell.html#torch.nn.RNNCell) ```python torch.nn.RNNCell(input_size, hidden_size, bias=True, nonlinearity='tanh', device=None, dtype=None) @@ -9,14 +9,14 @@ torch.nn.RNNCell(input_size, hidden_size, bias=True, nonlinearity='tanh', device paddle.nn.SimpleRNNCell(input_size, hidden_size, activation='tanh', weight_ih_attr=None, weight_hh_attr=None, bias_ih_attr=None, bias_hh_attr=None, name=None) ``` -两者功能一致但参数不一致,部分参数名不同,具体如下: +两者功能一致但输入参数用法不一致,且返回参数类型不同,具体如下: ### 参数映射 | PyTorch | PaddlePaddle | 备注 | | ------------- | ------------ | ------------------------------------------------------ | | input_size | input_size | 表示输入 x 的大小。 | | hidden_size | hidden_size | 表示隐藏状态 h 大小。 | -| bias | bias_ih_attr, bias_hh_attr | 是否使用偏置, Paddle 支持自定义偏置属性, torch 不支持,需要转写。 | +| bias | bias_ih_attr, bias_hh_attr | 是否使用偏置, Paddle 的 bias_ih_attr, bias_hh_attr 参数均需与 PyTorch 设置一致,需要转写。 | | nonlinearity | activation | 表示激活函数类型,仅参数名不一致。 | | - |weight_ih_attr| weight_ih 的参数, PyTorch 无此参数, Paddle 保持默认即可。 | | - |weight_hh_attr| weight_hh 的参数, PyTorch 无此参数, Paddle 保持默认即可。 | @@ -26,14 +26,22 @@ paddle.nn.SimpleRNNCell(input_size, hidden_size, activation='tanh', weight_ih_at ```python # PyTorch 写法 torch.nn.RNNCell(16, 32, bias=True) - # Paddle 写法 paddle.nn.SimpleRNNCell(16, 32) ``` ```python # PyTorch 写法 torch.nn.RNNCell(16, 32, bias=False) - # Paddle 写法 paddle.nn.SimpleRNNCell(16, 32, bias_ih_attr=False, bias_hh_attr=False) ``` +#### forward 类方法:前向传播 +```python +# PyTorch 写法 +rnn = torch.nn.RNNCell(2, 2) +result = rnn(inp, h0) + +# Paddle 写法 +rnn = paddle.nn.SimpleRNNCell(2, 2) +result = rnn(inp, h0)[0] +``` diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/torch/torch.ormqr.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/torch/torch.ormqr.md index 3e2973a7071..ba4e0fc6219 100644 --- a/docs/guides/model_convert/convert_from_pytorch/api_difference/torch/torch.ormqr.md +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/torch/torch.ormqr.md @@ -1,4 +1,4 @@ -## [ 仅参数名不一致 ]torch.ormqr +## [ torch 参数更多 ]torch.ormqr ### [torch.ormqr](https://pytorch.org/docs/stable/generated/torch.ormqr.html#torch.ormqr) @@ -12,13 +12,15 @@ torch.ormqr(input, tau, other, left=True, transpose=False, *, out=None) paddle.linalg.ormqr(x, tau, other, left=True, transpose=False) ``` +PyTorch 相比 Paddle 支持更多其他参数,具体如下: + ### 参数映射 | PyTorch | PaddlePaddle | 备注 | | --------- | ------------ | ---------------------------------------------- | | input | x | 输入的参数,用于表示矩阵 Q ,仅参数名字不一致 | -| tau | tau | Householder 反射系数,一致 | -| other | other | 用于矩阵乘积,一致 | +| input2 | tau | Householder 反射系数,一致 | +| input3 | other | 用于矩阵乘积,一致 | | left | left | 决定了矩阵乘积运算的顺序,一致 | | transpose | transpose | 决定矩阵 Q 是否共轭转置变换,一致 | | out | - | paddle 无此参数,需转写 | diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference_third_party/torchvision/torchvision.transform.functional.normalize.md b/docs/guides/model_convert/convert_from_pytorch/api_difference_third_party/torchvision/torchvision.transforms.functional.normalize.md similarity index 100% rename from docs/guides/model_convert/convert_from_pytorch/api_difference_third_party/torchvision/torchvision.transform.functional.normalize.md rename to docs/guides/model_convert/convert_from_pytorch/api_difference_third_party/torchvision/torchvision.transforms.functional.normalize.md