From 9cd5a15199094f7e0bbe51f6bd2a7525d34443b7 Mon Sep 17 00:00:00 2001 From: zty-king <17786324919@163.com> Date: Thu, 13 Nov 2025 13:33:10 +0000 Subject: [PATCH 1/2] fix the loss doc --- .../torch_more_args/torch.nn.BCELoss.md | 60 +++++-------------- .../torch.nn.BCEWithLogitsLoss.md | 60 +++++-------------- .../torch.nn.CosineEmbeddingLoss.md | 60 +++++-------------- .../torch.nn.CrossEntropyLoss.md | 59 +++++------------- .../torch.nn.HingeEmbeddingLoss.md | 59 +++++------------- .../torch_more_args/torch.nn.KLDivLoss.md | 56 +++++------------ .../torch_more_args/torch.nn.L1Loss.md | 56 ++++------------- .../torch_more_args/torch.nn.MSELoss.md | 56 ++++------------- .../torch.nn.MarginRankingLoss.md | 60 +++++-------------- .../torch.nn.MultiLabelMarginLoss.md | 55 ++++------------- .../torch.nn.MultiLabelSoftMarginLoss.md | 60 +++++-------------- .../torch.nn.MultiMarginLoss.md | 60 +++++-------------- .../torch_more_args/torch.nn.NLLLoss.md | 60 +++++-------------- .../torch.nn.PoissonNLLLoss.md | 60 +++++-------------- .../torch_more_args/torch.nn.SmoothL1Loss.md | 58 +++++------------- .../torch.nn.SoftMarginLoss.md | 56 ++++------------- .../torch.nn.TripletMarginLoss.md | 58 +++++------------- 17 files changed, 245 insertions(+), 748 deletions(-) diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.BCELoss.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.BCELoss.md index 3afcbc019a5..e617c7bcb06 100644 --- a/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.BCELoss.md +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.BCELoss.md @@ -25,65 +25,35 @@ PyTorch 相比 Paddle 支持更多其他参数,具体如下: | reduction | reduction | 表示应用于输出结果的计算方式。 | ### 转写示例 - - -#### size_average -size_average 为 True +#### reduction 为 sum ```python # PyTorch 写法 -torch.nn.BCELoss(size_average=True) +torch.nn.BCELoss(weight=w, size_average=False, reduce=True) +torch.nn.BCELoss(weight=w, size_average=Flase) # Paddle 写法 -paddle.nn.BCELoss(reduction='mean') +paddle.nn.BCELoss(weight=w, reduction='sum') ``` -size_average 为 False +#### reduction 为 mean ```python # PyTorch 写法 -torch.nn.BCELoss(size_average=False) +torch.nn.BCELoss(weight=w, size_average=True, reduce=True) +torch.nn.BCELoss(weight=w, reduce=True) +torch.nn.BCELoss(weight=w, size_average=True) +torch.nn.BCELoss(weight=w) # Paddle 写法 -paddle.nn.BCELoss(reduction='sum') +paddle.nn.BCELoss(weight=w, reduction='mean') ``` -#### reduce -reduce 为 True -```python -# PyTorch 写法 -torch.nn.BCELoss(reduce=True) -# Paddle 写法 -paddle.nn.BCELoss(reduction='sum') -``` -reduce 为 False -```python -# PyTorch 写法 -torch.nn.BCELoss(reduce=False) - -# Paddle 写法 -paddle.nn.BCELoss(reduction='none') -``` -#### reduction -reduction 为'none' -```python -# PyTorch 写法 -torch.nn.BCELoss(reduction='none') - -# Paddle 写法 -paddle.nn.BCELoss(reduction='none') -``` -reduction 为'mean' -```python -# PyTorch 写法 -torch.nn.BCELoss(reduction='mean') - -# Paddle 写法 -paddle.nn.BCELoss(reduction='mean') -``` -reduction 为'sum' +#### reduction 为 None ```python # PyTorch 写法 -torch.nn.BCELoss(reduction='sum') +torch.nn.BCELoss(weight=w, size_average=True, reduce=False) +torch.nn.BCELoss(weight=w, size_average=False, reduce=False) +torch.nn.BCELoss(weight=w, reduce=False) # Paddle 写法 -paddle.nn.BCELoss(reduction='sum') +paddle.nn.BCELoss(weight=w, reduction='None') ``` diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.BCEWithLogitsLoss.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.BCEWithLogitsLoss.md index 12ff093d8a3..996eb50e8ef 100644 --- a/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.BCEWithLogitsLoss.md +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.BCEWithLogitsLoss.md @@ -28,65 +28,35 @@ PyTorch 相比 Paddle 支持更多其他参数,具体如下: | pos_weight | pos_weight | 表示正类的权重。 | ### 转写示例 - - -#### size_average -size_average 为 True +#### reduction 为 sum ```python # PyTorch 写法 -torch.nn.BCEWithLogitsLoss(size_average=True) +torch.nn.BCEWithLogitsLoss(weight=w, size_average=False, reduce=True) +torch.nn.BCEWithLogitsLoss(weight=w, size_average=Flase) # Paddle 写法 -paddle.nn.BCEWithLogitsLoss(reduction='mean') +paddle.nn.BCEWithLogitsLoss(weight=w, reduction='sum') ``` -size_average 为 False +#### reduction 为 mean ```python # PyTorch 写法 -torch.nn.BCEWithLogitsLoss(size_average=False) +torch.nn.BCEWithLogitsLoss(weight=w, size_average=True, reduce=True) +torch.nn.BCEWithLogitsLoss(weight=w, reduce=True) +torch.nn.BCEWithLogitsLoss(weight=w, size_average=True) +torch.nn.BCEWithLogitsLoss(weight=w) # Paddle 写法 -paddle.nn.BCEWithLogitsLoss(reduction='sum') +paddle.nn.BCEWithLogitsLoss(weight=w, reduction='mean') ``` -#### reduce -reduce 为 True -```python -# PyTorch 写法 -torch.nn.BCEWithLogitsLoss(reduce=True) -# Paddle 写法 -paddle.nn.BCEWithLogitsLoss(reduction='sum') -``` -reduce 为 False -```python -# PyTorch 写法 -torch.nn.BCEWithLogitsLoss(reduce=False) - -# Paddle 写法 -paddle.nn.BCEWithLogitsLoss(reduction='none') -``` -#### reduction -reduction 为'none' -```python -# PyTorch 写法 -torch.nn.BCEWithLogitsLoss(reduction='none') - -# Paddle 写法 -paddle.nn.BCEWithLogitsLoss(reduction='none') -``` -reduction 为'mean' -```python -# PyTorch 写法 -torch.nn.BCEWithLogitsLoss(reduction='mean') - -# Paddle 写法 -paddle.nn.BCEWithLogitsLoss(reduction='mean') -``` -reduction 为'sum' +#### reduction 为 None ```python # PyTorch 写法 -torch.nn.BCEWithLogitsLoss(reduction='sum') +torch.nn.BCEWithLogitsLoss(weight=w, size_average=True, reduce=False) +torch.nn.BCEWithLogitsLoss(weight=w, size_average=False, reduce=False) +torch.nn.BCEWithLogitsLoss(weight=w, reduce=False) # Paddle 写法 -paddle.nn.BCEWithLogitsLoss(reduction='sum') +paddle.nn.BCEWithLogitsLoss(weight=w, reduction='None') ``` diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.CosineEmbeddingLoss.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.CosineEmbeddingLoss.md index e8da5b11fcc..c725e37320d 100644 --- a/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.CosineEmbeddingLoss.md +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.CosineEmbeddingLoss.md @@ -21,65 +21,35 @@ PyTorch 相比 Paddle 支持更多其他参数,具体如下: | reduction | reduction | 指定应用于输出结果的计算方式。 | ### 转写示例 - - -#### size_average -size_average 为 True +#### reduction 为 sum ```python # PyTorch 写法 -torch.nn.CosineEmbeddingLoss(size_average=True) +torch.nn.CosineEmbeddingLoss(margin=m, size_average=False, reduce=True) +torch.nn.CosineEmbeddingLoss(margin=m, size_average=Flase) # Paddle 写法 -paddle.nn.CosineEmbeddingLoss(reduction='mean') +paddle.nn.CosineEmbeddingLoss(margin=m, reduction='sum') ``` -size_average 为 False +#### reduction 为 mean ```python # PyTorch 写法 -torch.nn.CosineEmbeddingLoss(size_average=False) +torch.nn.CosineEmbeddingLoss(margin=m, size_average=True, reduce=True) +torch.nn.CosineEmbeddingLoss(margin=m, reduce=True) +torch.nn.CosineEmbeddingLoss(margin=m, size_average=True) +torch.nn.CosineEmbeddingLoss(margin=m) # Paddle 写法 -paddle.nn.CosineEmbeddingLoss(reduction='sum') +paddle.nn.CosineEmbeddingLoss(margin=m, reduction='mean') ``` -#### reduce -reduce 为 True -```python -# PyTorch 写法 -torch.nn.CosineEmbeddingLoss(reduce=True) -# Paddle 写法 -paddle.nn.CosineEmbeddingLoss(reduction='sum') -``` -reduce 为 False -```python -# PyTorch 写法 -torch.nn.CosineEmbeddingLoss(reduce=False) - -# Paddle 写法 -paddle.nn.CosineEmbeddingLoss(reduction='none') -``` -#### reduction -reduction 为'none' -```python -# PyTorch 写法 -torch.nn.CosineEmbeddingLoss(reduction='none') - -# Paddle 写法 -paddle.nn.CosineEmbeddingLoss(reduction='none') -``` -reduction 为'mean' -```python -# PyTorch 写法 -torch.nn.CosineEmbeddingLoss(reduction='mean') - -# Paddle 写法 -paddle.nn.CosineEmbeddingLoss(reduction='mean') -``` -reduction 为'sum' +#### reduction 为 None ```python # PyTorch 写法 -torch.nn.CosineEmbeddingLoss(reduction='sum') +torch.nn.CosineEmbeddingLoss(margin=m, size_average=True, reduce=False) +torch.nn.CosineEmbeddingLoss(margin=m, size_average=False, reduce=False) +torch.nn.CosineEmbeddingLoss(margin=m, reduce=False) # Paddle 写法 -paddle.nn.CosineEmbeddingLoss(reduction='sum') +paddle.nn.CosineEmbeddingLoss(margin=m, reduction='None') ``` diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.CrossEntropyLoss.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.CrossEntropyLoss.md index ce5abfce407..4b29abea431 100644 --- a/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.CrossEntropyLoss.md +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.CrossEntropyLoss.md @@ -36,65 +36,36 @@ PyTorch 相比 Paddle 支持更多其他参数,具体如下: | - | axis | 进行 softmax 计算的维度索引,PyTorch 无此参数,Paddle 保持默认即可。 | ### 转写示例 - - -#### size_average -size_average 为 True -```python -# PyTorch 写法 -torch.nn.CrossEntropyLoss(size_average=True) - -# Paddle 写法 -paddle.nn.CrossEntropyLoss(reduction='mean') -``` - -size_average 为 False +#### reduction 为 sum ```python # PyTorch 写法 -torch.nn.CrossEntropyLoss(size_average=False) +torch.nn.CrossEntropyLoss(weight=w, size_average=False, reduce=True) +torch.nn.CrossEntropyLoss(weight=w, size_average=Flase) # Paddle 写法 -paddle.nn.CrossEntropyLoss(reduction='sum') +paddle.nn.CrossEntropyLoss(weight=w, reduction='sum') ``` -#### reduce -reduce 为 True -```python -# PyTorch 写法 -torch.nn.CrossEntropyLoss(reduce=True) -# Paddle 写法 -paddle.nn.CrossEntropyLoss(reduction='sum') -``` -reduce 为 False +#### reduction 为 mean ```python # PyTorch 写法 -torch.nn.CrossEntropyLoss(reduce=False) +torch.nn.CrossEntropyLoss(weight=w, size_average=True, reduce=True) +torch.nn.CrossEntropyLoss(weight=w, reduce=True) +torch.nn.CrossEntropyLoss(weight=w, size_average=True) +torch.nn.CrossEntropyLoss(weight=w) # Paddle 写法 -paddle.nn.CrossEntropyLoss(reduction='none') +paddle.nn.CrossEntropyLoss(weight=w, reduction='mean') ``` -#### reduction -reduction 为'none' -```python -# PyTorch 写法 -torch.nn.CrossEntropyLoss(reduction='none') -# Paddle 写法 -paddle.nn.CrossEntropyLoss(reduction='none') -``` -reduction 为'mean' +#### reduction 为 None ```python # PyTorch 写法 -torch.nn.CrossEntropyLoss(reduction='mean') +torch.nn.CrossEntropyLoss(weight=w, size_average=True, reduce=False) +torch.nn.CrossEntropyLoss(weight=w, size_average=False, reduce=False) +torch.nn.CrossEntropyLoss(weight=w, reduce=False) # Paddle 写法 -paddle.nn.CrossEntropyLoss(reduction='mean') +paddle.nn.CrossEntropyLoss(weight=w, reduction='None') ``` -reduction 为'sum' -```python -# PyTorch 写法 -torch.nn.CrossEntropyLoss(reduction='sum') -# Paddle 写法 -paddle.nn.CrossEntropyLoss(reduction='sum') -``` diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.HingeEmbeddingLoss.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.HingeEmbeddingLoss.md index 55fe740b4c5..f5cbecd141f 100644 --- a/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.HingeEmbeddingLoss.md +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.HingeEmbeddingLoss.md @@ -26,65 +26,36 @@ PyTorch 相比 Paddle 支持更多其他参数,具体如下: | reduction | reduction | 表示应用于输出结果的计算方式。 | ### 转写示例 - - -#### size_average -size_average 为 True -```python -# PyTorch 写法 -torch.nn.HingeEmbeddingLoss(size_average=True) - -# Paddle 写法 -paddle.nn.HingeEmbeddingLoss(reduction='mean') -``` - -size_average 为 False +#### reduction 为 sum ```python # PyTorch 写法 -torch.nn.HingeEmbeddingLoss(size_average=False) +torch.nn.HingeEmbeddingLoss(margin=m, size_average=False, reduce=True) +torch.nn.HingeEmbeddingLoss(margin=m, size_average=Flase) # Paddle 写法 -paddle.nn.HingeEmbeddingLoss(reduction='sum') +paddle.nn.HingeEmbeddingLoss(margin=m, reduction='sum') ``` -#### reduce -reduce 为 True -```python -# PyTorch 写法 -torch.nn.HingeEmbeddingLoss(reduce=True) -# Paddle 写法 -paddle.nn.HingeEmbeddingLoss(reduction='sum') -``` -reduce 为 False +#### reduction 为 mean ```python # PyTorch 写法 -torch.nn.HingeEmbeddingLoss(reduce=False) +torch.nn.HingeEmbeddingLoss(margin=m, size_average=True, reduce=True) +torch.nn.HingeEmbeddingLoss(margin=m, reduce=True) +torch.nn.HingeEmbeddingLoss(margin=m, size_average=True) +torch.nn.HingeEmbeddingLoss(margin=m) # Paddle 写法 -paddle.nn.HingeEmbeddingLoss(reduction='none') +paddle.nn.HingeEmbeddingLoss(margin=m, reduction='mean') ``` -#### reduction -reduction 为'none' -```python -# PyTorch 写法 -torch.nn.HingeEmbeddingLoss(reduction='none') -# Paddle 写法 -paddle.nn.HingeEmbeddingLoss(reduction='none') -``` -reduction 为'mean' +#### reduction 为 None ```python # PyTorch 写法 -torch.nn.HingeEmbeddingLoss(reduction='mean') +torch.nn.HingeEmbeddingLoss(margin=m, size_average=True, reduce=False) +torch.nn.HingeEmbeddingLoss(margin=m, size_average=False, reduce=False) +torch.nn.HingeEmbeddingLoss(margin=m, reduce=False) # Paddle 写法 -paddle.nn.HingeEmbeddingLoss(reduction='mean') +paddle.nn.HingeEmbeddingLoss(margin=m, reduction='None') ``` -reduction 为'sum' -```python -# PyTorch 写法 -torch.nn.HingeEmbeddingLoss(reduction='sum') -# Paddle 写法 -paddle.nn.HingeEmbeddingLoss(reduction='sum') -``` diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.KLDivLoss.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.KLDivLoss.md index f5aecab138b..0023da3c1ef 100644 --- a/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.KLDivLoss.md +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.KLDivLoss.md @@ -24,65 +24,37 @@ PyTorch 相比 Paddle 支持更多其他参数,具体如下: | log_target | log_target | 指定目标是否属于 log 空间。 | ### 转写示例 - - -#### size_average -size_average 为 True +#### reduction 为 sum ```python # PyTorch 写法 -torch.nn.KLDivLoss(size_average=True) - -# Paddle 写法 -paddle.nn.KLDivLoss(reduction='mean') -``` - -size_average 为 False -```python -# PyTorch 写法 -torch.nn.KLDivLoss(size_average=False) +torch.nn.KLDivLoss(size_average=False, reduce=True) +torch.nn.KLDivLoss(size_average=Flase) # Paddle 写法 paddle.nn.KLDivLoss(reduction='sum') ``` -#### reduce -reduce 为 True + +#### reduction 为 mean ```python # PyTorch 写法 +torch.nn.KLDivLoss(size_average=True, reduce=True) torch.nn.KLDivLoss(reduce=True) +torch.nn.KLDivLoss(size_average=True) +torch.nn.KLDivLoss() # Paddle 写法 -paddle.nn.KLDivLoss(reduction='sum') +paddle.nn.KLDivLoss(reduction='mean') ``` -reduce 为 False -```python -# PyTorch 写法 -torch.nn.KLDivLoss(reduce=False) -# Paddle 写法 -paddle.nn.KLDivLoss(reduction='none') -``` -#### reduction -reduction 为'none' +#### reduction 为 None ```python # PyTorch 写法 -torch.nn.KLDivLoss(reduction='none') +torch.nn.KLDivLoss(size_average=True, reduce=False) +torch.nn.KLDivLoss(size_average=False, reduce=False) +torch.nn.KLDivLoss(reduce=False) # Paddle 写法 -paddle.nn.KLDivLoss(reduction='none') +paddle.nn.KLDivLoss(reduction='None') ``` -reduction 为'mean' -```python -# PyTorch 写法 -torch.nn.KLDivLoss(reduction='mean') -# Paddle 写法 -paddle.nn.KLDivLoss(reduction='mean') -``` -reduction 为'sum' -```python -# PyTorch 写法 -torch.nn.KLDivLoss(reduction='sum') -# Paddle 写法 -paddle.nn.KLDivLoss(reduction='sum') -``` diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.L1Loss.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.L1Loss.md index 39592b67eac..e60bfb78564 100644 --- a/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.L1Loss.md +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.L1Loss.md @@ -22,65 +22,35 @@ PyTorch 相比 Paddle 支持更多其他参数,具体如下: | reduction | reduction | 表示对输出结果的计算方式。 | ### 转写示例 - - -#### size_average -size_average 为 True -```python -# PyTorch 写法 -torch.nn.L1Loss(size_average=True) - -# Paddle 写法 -paddle.nn.L1Loss(reduction='mean') -``` - -size_average 为 False +#### reduction 为 sum ```python # PyTorch 写法 +torch.nn.L1Loss(size_average=False, reduce=True) torch.nn.L1Loss(size_average=False) # Paddle 写法 paddle.nn.L1Loss(reduction='sum') ``` -#### reduce -reduce 为 True -```python -# PyTorch 写法 -torch.nn.L1Loss(reduce=True) - -# Paddle 写法 -paddle.nn.L1Loss(reduction='sum') -``` -reduce 为 False -```python -# PyTorch 写法 -torch.nn.L1Loss(reduce=False) - -# Paddle 写法 -paddle.nn.L1Loss(reduction='none') -``` -#### reduction -reduction 为'none' -```python -# PyTorch 写法 -torch.nn.L1Loss(reduction='none') -# Paddle 写法 -paddle.nn.L1Loss(reduction='none') -``` -reduction 为'mean' +#### reduction 为 mean ```python # PyTorch 写法 -torch.nn.L1Loss(reduction='mean') +torch.nn.L1Loss(size_average=True, reduce=True) +torch.nn.L1Loss(reduce=True) +torch.nn.L1Loss(size_average=True) +torch.nn.L1Loss() # Paddle 写法 paddle.nn.L1Loss(reduction='mean') ``` -reduction 为'sum' + +#### reduction 为 None ```python # PyTorch 写法 -torch.nn.L1Loss(reduction='sum') +torch.nn.L1Loss(size_average=True, reduce=False) +torch.nn.L1Loss(size_average=False, reduce=False) +torch.nn.L1Loss(reduce=False) # Paddle 写法 -paddle.nn.L1Loss(reduction='sum') +paddle.nn.L1Loss(reduction='None') ``` diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.MSELoss.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.MSELoss.md index 60ae87050e3..9b9626e6917 100644 --- a/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.MSELoss.md +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.MSELoss.md @@ -21,65 +21,35 @@ PyTorch 相比 Paddle 支持更多其他参数,具体如下: | reduction | reduction | 表示对输出结果的计算方式。 | ### 转写示例 - - -#### size_average -size_average 为 True -```python -# PyTorch 写法 -torch.nn.MSELoss(size_average=True) - -# Paddle 写法 -paddle.nn.MSELoss(reduction='mean') -``` - -size_average 为 False +#### reduction 为 sum ```python # PyTorch 写法 +torch.nn.MSELoss(size_average=False, reduce=True) torch.nn.MSELoss(size_average=False) # Paddle 写法 paddle.nn.MSELoss(reduction='sum') ``` -#### reduce -reduce 为 True -```python -# PyTorch 写法 -torch.nn.MSELoss(reduce=True) - -# Paddle 写法 -paddle.nn.MSELoss(reduction='sum') -``` -reduce 为 False -```python -# PyTorch 写法 -torch.nn.MSELoss(reduce=False) - -# Paddle 写法 -paddle.nn.MSELoss(reduction='none') -``` -#### reduction -reduction 为'none' -```python -# PyTorch 写法 -torch.nn.MSELoss(reduction='none') -# Paddle 写法 -paddle.nn.MSELoss(reduction='none') -``` -reduction 为'mean' +#### reduction 为 mean ```python # PyTorch 写法 -torch.nn.MSELoss(reduction='mean') +torch.nn.MSELoss(size_average=True, reduce=True) +torch.nn.MSELoss(reduce=True) +torch.nn.MSELoss(size_average=True) +torch.nn.MSELoss() # Paddle 写法 paddle.nn.MSELoss(reduction='mean') ``` -reduction 为'sum' + +#### reduction 为 None ```python # PyTorch 写法 -torch.nn.MSELoss(reduction='sum') +torch.nn.MSELoss(size_average=True, reduce=False) +torch.nn.MSELoss(size_average=False, reduce=False) +torch.nn.MSELoss(reduce=False) # Paddle 写法 -paddle.nn.MSELoss(reduction='sum') +paddle.nn.MSELoss(reduction='None') ``` diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.MarginRankingLoss.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.MarginRankingLoss.md index b10971244cf..74af581732b 100644 --- a/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.MarginRankingLoss.md +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.MarginRankingLoss.md @@ -26,65 +26,35 @@ PyTorch 相比 Paddle 支持更多其他参数,具体如下: | reduction | reduction | 表示应用于输出结果的计算方式。 | ### 转写示例 - - -#### size_average -size_average 为 True +#### reduction 为 sum ```python # PyTorch 写法 -torch.nn.MarginRankingLoss(size_average=True) +torch.nn.MarginRankingLoss(margin=m, size_average=False, reduce=True) +torch.nn.MarginRankingLoss(margin=m, size_average=False) # Paddle 写法 -paddle.nn.MarginRankingLoss(reduction='mean') +paddle.nn.MarginRankingLoss(margin=m, reduction='sum') ``` -size_average 为 False +#### reduction 为 mean ```python # PyTorch 写法 -torch.nn.MarginRankingLoss(size_average=False) +torch.nn.MarginRankingLoss(margin=m, size_average=True, reduce=True) +torch.nn.MarginRankingLoss(margin=m, reduce=True) +torch.nn.MarginRankingLoss(margin=m, size_average=True) +torch.nn.MarginRankingLoss(margin=m) # Paddle 写法 -paddle.nn.MarginRankingLoss(reduction='sum') +paddle.nn.MarginRankingLoss(margin=m, reduction='mean') ``` -#### reduce -reduce 为 True -```python -# PyTorch 写法 -torch.nn.MarginRankingLoss(reduce=True) -# Paddle 写法 -paddle.nn.MarginRankingLoss(reduction='sum') -``` -reduce 为 False -```python -# PyTorch 写法 -torch.nn.MarginRankingLoss(reduce=False) - -# Paddle 写法 -paddle.nn.MarginRankingLoss(reduction='none') -``` -#### reduction -reduction 为'none' -```python -# PyTorch 写法 -torch.nn.MarginRankingLoss(reduction='none') - -# Paddle 写法 -paddle.nn.MarginRankingLoss(reduction='none') -``` -reduction 为'mean' -```python -# PyTorch 写法 -torch.nn.MarginRankingLoss(reduction='mean') - -# Paddle 写法 -paddle.nn.MarginRankingLoss(reduction='mean') -``` -reduction 为'sum' +#### reduction 为 None ```python # PyTorch 写法 -torch.nn.MarginRankingLoss(reduction='sum') +torch.nn.MarginRankingLoss(margin=m, size_average=True, reduce=False) +torch.nn.MarginRankingLoss(margin=m, size_average=False, reduce=False) +torch.nn.MarginRankingLoss(margin=m, reduce=False) # Paddle 写法 -paddle.nn.MarginRankingLoss(reduction='sum') +paddle.nn.MarginRankingLoss(margin=m, reduction='None') ``` diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.MultiLabelMarginLoss.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.MultiLabelMarginLoss.md index fc76c63fcca..0124ba24252 100644 --- a/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.MultiLabelMarginLoss.md +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.MultiLabelMarginLoss.md @@ -20,65 +20,36 @@ PyTorch 相比 Paddle 支持更多其他参数,具体如下: | reduction | reduction | 指定应用于输出结果的计算方式。 | ### 转写示例 - - -#### size_average -size_average 为 True -```python -# PyTorch 写法 -torch.nn.MultiLabelMarginLoss(size_average=True) - -# Paddle 写法 -paddle.nn.MultiLabelMarginLoss(reduction='mean') -``` - -size_average 为 False +#### reduction 为 sum ```python # PyTorch 写法 +torch.nn.MultiLabelMarginLoss(size_average=False, reduce=True) torch.nn.MultiLabelMarginLoss(size_average=False) # Paddle 写法 paddle.nn.MultiLabelMarginLoss(reduction='sum') ``` -#### reduce -reduce 为 True -```python -# PyTorch 写法 -torch.nn.MultiLabelMarginLoss(reduce=True) -# Paddle 写法 -paddle.nn.MultiLabelMarginLoss(reduction='sum') -``` -reduce 为 False +#### reduction 为 mean ```python # PyTorch 写法 -torch.nn.MultiLabelMarginLoss(reduce=False) +torch.nn.MultiLabelMarginLoss(size_average=True, reduce=True) +torch.nn.MultiLabelMarginLoss(reduce=True) +torch.nn.MultiLabelMarginLoss(size_average=True) +torch.nn.MultiLabelMarginLoss() # Paddle 写法 -paddle.nn.MultiLabelMarginLoss(reduction='none') +paddle.nn.MultiLabelMarginLoss(reduction='mean') ``` -#### reduction -reduction 为'none' -```python -# PyTorch 写法 -torch.nn.MultiLabelMarginLoss(reduction='none') -# Paddle 写法 -paddle.nn.MultiLabelMarginLoss(reduction='none') -``` -reduction 为'mean' +#### reduction 为 None ```python # PyTorch 写法 -torch.nn.MultiLabelMarginLoss(reduction='mean') +torch.nn.MultiLabelMarginLoss(size_average=True, reduce=False) +torch.nn.MultiLabelMarginLoss(size_average=False, reduce=False) +torch.nn.MultiLabelMarginLoss(reduce=False) # Paddle 写法 -paddle.nn.MultiLabelMarginLoss(reduction='mean') +paddle.nn.MultiLabelMarginLoss(reduction='None') ``` -reduction 为'sum' -```python -# PyTorch 写法 -torch.nn.MultiLabelMarginLoss(reduction='sum') -# Paddle 写法 -paddle.nn.MultiLabelMarginLoss(reduction='sum') -``` diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.MultiLabelSoftMarginLoss.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.MultiLabelSoftMarginLoss.md index a96567650fa..ff04ebc468c 100644 --- a/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.MultiLabelSoftMarginLoss.md +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.MultiLabelSoftMarginLoss.md @@ -21,65 +21,35 @@ PyTorch 相比 Paddle 支持更多其他参数,具体如下: | reduction | reduction | 指定应用于输出结果的计算方式。 | ### 转写示例 - - -#### size_average -size_average 为 True +#### reduction 为 sum ```python # PyTorch 写法 -torch.nn.MultiLabelSoftMarginLoss(size_average=True) +torch.nn.MultiLabelSoftMarginLoss(weight=w, size_average=False, reduce=True) +torch.nn.MultiLabelSoftMarginLoss(weight=w, size_average=False) # Paddle 写法 -paddle.nn.MultiLabelSoftMarginLoss(reduction='mean') +paddle.nn.MultiLabelSoftMarginLoss(weight=w, reduction='sum') ``` -size_average 为 False +#### reduction 为 mean ```python # PyTorch 写法 -torch.nn.MultiLabelSoftMarginLoss(size_average=False) +torch.nn.MultiLabelSoftMarginLoss(weight=w, size_average=True, reduce=True) +torch.nn.MultiLabelSoftMarginLoss(weight=w, reduce=True) +torch.nn.MultiLabelSoftMarginLoss(weight=w, size_average=True) +torch.nn.MultiLabelSoftMarginLoss(weight=w) # Paddle 写法 -paddle.nn.MultiLabelSoftMarginLoss(reduction='sum') +paddle.nn.MultiLabelSoftMarginLoss(weight=w, reduction='mean') ``` -#### reduce -reduce 为 True -```python -# PyTorch 写法 -torch.nn.MultiLabelSoftMarginLoss(reduce=True) -# Paddle 写法 -paddle.nn.MultiLabelSoftMarginLoss(reduction='sum') -``` -reduce 为 False -```python -# PyTorch 写法 -torch.nn.MultiLabelSoftMarginLoss(reduce=False) - -# Paddle 写法 -paddle.nn.MultiLabelSoftMarginLoss(reduction='none') -``` -#### reduction -reduction 为'none' -```python -# PyTorch 写法 -torch.nn.MultiLabelSoftMarginLoss(reduction='none') - -# Paddle 写法 -paddle.nn.MultiLabelSoftMarginLoss(reduction='none') -``` -reduction 为'mean' -```python -# PyTorch 写法 -torch.nn.MultiLabelSoftMarginLoss(reduction='mean') - -# Paddle 写法 -paddle.nn.MultiLabelSoftMarginLoss(reduction='mean') -``` -reduction 为'sum' +#### reduction 为 None ```python # PyTorch 写法 -torch.nn.MultiLabelSoftMarginLoss(reduction='sum') +torch.nn.MultiLabelSoftMarginLoss(weight=w, size_average=True, reduce=False) +torch.nn.MultiLabelSoftMarginLoss(weight=w, size_average=False, reduce=False) +torch.nn.MultiLabelSoftMarginLoss(weight=w, reduce=False) # Paddle 写法 -paddle.nn.MultiLabelSoftMarginLoss(reduction='sum') +paddle.nn.MultiLabelSoftMarginLoss(weight=w, reduction='None') ``` diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.MultiMarginLoss.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.MultiMarginLoss.md index 05179773cf6..828e79aeb93 100644 --- a/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.MultiMarginLoss.md +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.MultiMarginLoss.md @@ -23,65 +23,35 @@ PyTorch 相比 Paddle 支持更多其他参数,具体如下: | reduction | reduction | 指定应用于输出结果的计算方式,可选值有 `none`、`mean` 和 `sum`。默认为 `mean`,计算 mini-batch loss 均值。设置为 `sum` 时,计算 mini-batch loss 的总和。设置为 `none` 时,则返回 loss Tensor。默认值下为 `mean`。 | ### 转写示例 - - -#### size_average -size_average 为 True +#### reduction 为 sum ```python # PyTorch 写法 -torch.nn.MultiMarginLoss(size_average=True) +torch.nn.MultiMarginLoss(p=1, margin=1.0, weight=w, size_average=False, reduce=True) +torch.nn.MultiMarginLoss(p=1, margin=1.0, weight=w, size_average=False) # Paddle 写法 -paddle.nn.MultiMarginLoss(reduction='mean') +paddle.nn.MultiMarginLoss(p=1, margin=1.0, weight=w, reduction='sum') ``` -size_average 为 False +#### reduction 为 mean ```python # PyTorch 写法 -torch.nn.MultiMarginLoss(size_average=False) +torch.nn.MultiMarginLoss(p=1, margin=1.0, weight=w, size_average=True, reduce=True) +torch.nn.MultiMarginLoss(p=1, margin=1.0, weight=w, reduce=True) +torch.nn.MultiMarginLoss(p=1, margin=1.0, weight=w, size_average=True) +torch.nn.MultiMarginLoss(p=1, margin=1.0, weight=w) # Paddle 写法 -paddle.nn.MultiMarginLoss(reduction='sum') +paddle.nn.MultiMarginLoss(p=1, margin=1.0, weight=w, reduction='mean') ``` -#### reduce -reduce 为 True -```python -# PyTorch 写法 -torch.nn.MultiMarginLoss(reduce=True) -# Paddle 写法 -paddle.nn.MultiMarginLoss(reduction='sum') -``` -reduce 为 False -```python -# PyTorch 写法 -torch.nn.MultiMarginLoss(reduce=False) - -# Paddle 写法 -paddle.nn.MultiMarginLoss(reduction='none') -``` -#### reduction -reduction 为'none' -```python -# PyTorch 写法 -torch.nn.MultiMarginLoss(reduction='none') - -# Paddle 写法 -paddle.nn.MultiMarginLoss(reduction='none') -``` -reduction 为'mean' -```python -# PyTorch 写法 -torch.nn.MultiMarginLoss(reduction='mean') - -# Paddle 写法 -paddle.nn.MultiMarginLoss(reduction='mean') -``` -reduction 为'sum' +#### reduction 为 None ```python # PyTorch 写法 -torch.nn.MultiMarginLoss(reduction='sum') +torch.nn.MultiMarginLoss(p=1, margin=1.0, weight=w, size_average=True, reduce=False) +torch.nn.MultiMarginLoss(p=1, margin=1.0, weight=w, size_average=False, reduce=False) +torch.nn.MultiMarginLoss(p=1, margin=1.0, weight=w, reduce=False) # Paddle 写法 -paddle.nn.MultiMarginLoss(reduction='sum') +paddle.nn.MultiMarginLoss(p=1, margin=1.0, weight=w, reduction='None') ``` diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.NLLLoss.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.NLLLoss.md index 8a1904b4d65..0614396b206 100644 --- a/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.NLLLoss.md +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.NLLLoss.md @@ -29,65 +29,35 @@ PyTorch 相比 Paddle 支持更多其他参数,具体如下: | reduction | reduction | 表示应用于输出结果的计算方式。 | ### 转写示例 - - -#### size_average -size_average 为 True +#### reduction 为 sum ```python # PyTorch 写法 -torch.nn.NLLLoss(size_average=True) +torch.nn.NLLLoss(weight=w, ignore_index=-100, size_average=False, reduce=True) +torch.nn.NLLLoss(weight=w, ignore_index=-100, size_average=False) # Paddle 写法 -paddle.nn.NLLLoss(reduction='mean') +paddle.nn.NLLLoss(weight=w, ignore_index=-100, reduction='sum') ``` -size_average 为 False +#### reduction 为 mean ```python # PyTorch 写法 -torch.nn.NLLLoss(size_average=False) +torch.nn.NLLLoss(weight=w, ignore_index=-100, size_average=True, reduce=True) +torch.nn.NLLLoss(weight=w, ignore_index=-100, reduce=True) +torch.nn.NLLLoss(weight=w, ignore_index=-100, size_average=True) +torch.nn.NLLLoss(weight=w, ignore_index=-100) # Paddle 写法 -paddle.nn.NLLLoss(reduction='sum') +paddle.nn.NLLLoss(weight=w, ignore_index=-100, reduction='mean') ``` -#### reduce -reduce 为 True -```python -# PyTorch 写法 -torch.nn.NLLLoss(reduce=True) -# Paddle 写法 -paddle.nn.NLLLoss(reduction='sum') -``` -reduce 为 False -```python -# PyTorch 写法 -torch.nn.NLLLoss(reduce=False) - -# Paddle 写法 -paddle.nn.NLLLoss(reduction='none') -``` -#### reduction -reduction 为'none' -```python -# PyTorch 写法 -torch.nn.NLLLoss(reduction='none') - -# Paddle 写法 -paddle.nn.NLLLoss(reduction='none') -``` -reduction 为'mean' -```python -# PyTorch 写法 -torch.nn.NLLLoss(reduction='mean') - -# Paddle 写法 -paddle.nn.NLLLoss(reduction='mean') -``` -reduction 为'sum' +#### reduction 为 None ```python # PyTorch 写法 -torch.nn.NLLLoss(reduction='sum') +torch.nn.NLLLoss(weight=w, ignore_index=-100, size_average=True, reduce=False) +torch.nn.NLLLoss(weight=w, ignore_index=-100, size_average=False, reduce=False) +torch.nn.NLLLoss(weight=w, ignore_index=-100, reduce=False) # Paddle 写法 -paddle.nn.NLLLoss(reduction='sum') +paddle.nn.NLLLoss(weight=w, ignore_index=-100, reduction='None') ``` diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.PoissonNLLLoss.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.PoissonNLLLoss.md index f7161f5e8b2..a05011b5e07 100644 --- a/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.PoissonNLLLoss.md +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.PoissonNLLLoss.md @@ -23,65 +23,35 @@ PyTorch 相比 Paddle 支持更多其他参数,具体如下: | reduction | reduction | 指定应用于输出结果的计算方式,可选值有 `none`、`mean` 和 `sum`。默认为 `mean`,计算 mini-batch loss 均值。设置为 `sum` 时,计算 mini-batch loss 的总和。设置为 `none` 时,则返回 loss Tensor。默认值下为 `mean`。两者完全一致。 | ### 转写示例 - - -#### size_average -size_average 为 True +#### reduction 为 sum ```python # PyTorch 写法 -torch.nn.PoissonNLLLoss(size_average=True) +torch.nn.PoissonNLLLoss(log_input=True, full=False, eps=1e-8, size_average=False, reduce=True) +torch.nn.PoissonNLLLoss(log_input=True, full=False, eps=1e-8, size_average=False) # Paddle 写法 -paddle.nn.PoissonNLLLoss(reduction='mean') +paddle.nn.PoissonNLLLoss(log_input=True, full=False, epsilon=1e-8, reduction='sum') ``` -size_average 为 False +#### reduction 为 mean ```python # PyTorch 写法 -torch.nn.PoissonNLLLoss(size_average=False) +torch.nn.PoissonNLLLoss(log_input=True, full=False, eps=1e-8, size_average=True, reduce=True) +torch.nn.PoissonNLLLoss(log_input=True, full=False, eps=1e-8, reduce=True) +torch.nn.PoissonNLLLoss(log_input=True, full=False, eps=1e-8, size_average=True) +torch.nn.PoissonNLLLoss(log_input=True, full=False, eps=1e-8) # Paddle 写法 -paddle.nn.PoissonNLLLoss(reduction='sum') +paddle.nn.PoissonNLLLoss(log_input=True, full=False, epsilon=1e-8, reduction='mean') ``` -#### reduce -reduce 为 True -```python -# PyTorch 写法 -torch.nn.PoissonNLLLoss(reduce=True) -# Paddle 写法 -paddle.nn.PoissonNLLLoss(reduction='sum') -``` -reduce 为 False -```python -# PyTorch 写法 -torch.nn.PoissonNLLLoss(reduce=False) - -# Paddle 写法 -paddle.nn.PoissonNLLLoss(reduction='none') -``` -#### reduction -reduction 为'none' -```python -# PyTorch 写法 -torch.nn.PoissonNLLLoss(reduction='none') - -# Paddle 写法 -paddle.nn.PoissonNLLLoss(reduction='none') -``` -reduction 为'mean' -```python -# PyTorch 写法 -torch.nn.PoissonNLLLoss(reduction='mean') - -# Paddle 写法 -paddle.nn.PoissonNLLLoss(reduction='mean') -``` -reduction 为'sum' +#### reduction 为 None ```python # PyTorch 写法 -torch.nn.PoissonNLLLoss(reduction='sum') +torch.nn.PoissonNLLLoss(log_input=True, full=False, eps=1e-8, size_average=True, reduce=False) +torch.nn.PoissonNLLLoss(log_input=True, full=False, eps=1e-8, size_average=False, reduce=False) +torch.nn.PoissonNLLLoss(log_input=True, full=False, eps=1e-8, reduce=False) # Paddle 写法 -paddle.nn.PoissonNLLLoss(reduction='sum') +paddle.nn.PoissonNLLLoss(log_input=True, full=False, epsilon=1e-8, reduction='None') ``` diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.SmoothL1Loss.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.SmoothL1Loss.md index 596a6ca811d..596979cb9fa 100644 --- a/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.SmoothL1Loss.md +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.SmoothL1Loss.md @@ -27,65 +27,35 @@ PyTorch 相比 Paddle 支持更多其他参数,具体如下: | - | is_huber | 控制 huber_loss 与 smooth_l1_loss 的开关,Paddle 需设置为 False 。 | ### 转写示例 - - -#### size_average -size_average 为 True +#### reduction 为 sum ```python # PyTorch 写法 -torch.nn.SmoothL1Loss(size_average=True) +torch.nn.SmoothL1Loss(beta=1.0, size_average=False, reduce=True) +torch.nn.SmoothL1Loss(beta=1.0, size_average=False) # Paddle 写法 -paddle.nn.SmoothL1Loss(reduction='mean') +paddle.nn.SmoothL1Loss(reduction='sum', is_huber=False) ``` -size_average 为 False -```python -# PyTorch 写法 -torch.nn.SmoothL1Loss(size_average=False) - -# Paddle 写法 -paddle.nn.SmoothL1Loss(reduction='sum') -``` -#### reduce -reduce 为 True +#### reduction 为 mean ```python # PyTorch 写法 +torch.nn.SmoothL1Loss(size_average=True, reduce=True) torch.nn.SmoothL1Loss(reduce=True) +torch.nn.SmoothL1Loss(size_average=True) +torch.nn.SmoothL1Loss() # Paddle 写法 -paddle.nn.SmoothL1Loss(reduction='sum') -``` -reduce 为 False -```python -# PyTorch 写法 -torch.nn.SmoothL1Loss(reduce=False) - -# Paddle 写法 -paddle.nn.SmoothL1Loss(reduction='none') -``` -#### reduction -reduction 为'none' -```python -# PyTorch 写法 -torch.nn.SmoothL1Loss(reduction='none') - -# Paddle 写法 -paddle.nn.SmoothL1Loss(reduction='none') +paddle.nn.SmoothL1Loss(reduction='mean',is_huber=False) ``` -reduction 为'mean' -```python -# PyTorch 写法 -torch.nn.SmoothL1Loss(reduction='mean') -# Paddle 写法 -paddle.nn.SmoothL1Loss(reduction='mean') -``` -reduction 为'sum' +#### reduction 为 None ```python # PyTorch 写法 -torch.nn.SmoothL1Loss(reduction='sum') +torch.nn.SmoothL1Loss(size_average=True, reduce=False) +torch.nn.SmoothL1Loss(size_average=False, reduce=False) +torch.nn.SmoothL1Loss(reduce=False) # Paddle 写法 -paddle.nn.SmoothL1Loss(reduction='sum') +paddle.nn.SmoothL1Loss(reduction='None',is_huber=False) ``` diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.SoftMarginLoss.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.SoftMarginLoss.md index 5aa71ee2502..99937b4e3d7 100644 --- a/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.SoftMarginLoss.md +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.SoftMarginLoss.md @@ -23,65 +23,35 @@ PyTorch 相比 Paddle 支持更多其他参数,具体如下: | reduction | reduction | 表示应用于输出结果的计算方式。 | ### 转写示例 - - -#### size_average -size_average 为 True -```python -# PyTorch 写法 -torch.nn.SoftMarginLoss(size_average=True) - -# Paddle 写法 -paddle.nn.SoftMarginLoss(reduction='mean') -``` - -size_average 为 False +#### reduction 为 sum ```python # PyTorch 写法 +torch.nn.SoftMarginLoss(size_average=False, reduce=True) torch.nn.SoftMarginLoss(size_average=False) # Paddle 写法 paddle.nn.SoftMarginLoss(reduction='sum') ``` -#### reduce -reduce 为 True -```python -# PyTorch 写法 -torch.nn.SoftMarginLoss(reduce=True) - -# Paddle 写法 -paddle.nn.SoftMarginLoss(reduction='sum') -``` -reduce 为 False -```python -# PyTorch 写法 -torch.nn.SoftMarginLoss(reduce=False) - -# Paddle 写法 -paddle.nn.SoftMarginLoss(reduction='none') -``` -#### reduction -reduction 为'none' -```python -# PyTorch 写法 -torch.nn.SoftMarginLoss(reduction='none') -# Paddle 写法 -paddle.nn.SoftMarginLoss(reduction='none') -``` -reduction 为'mean' +#### reduction 为 mean ```python # PyTorch 写法 -torch.nn.SoftMarginLoss(reduction='mean') +torch.nn.SoftMarginLoss(size_average=True, reduce=True) +torch.nn.SoftMarginLoss(reduce=True) +torch.nn.SoftMarginLoss(size_average=True) +torch.nn.SoftMarginLoss() # Paddle 写法 paddle.nn.SoftMarginLoss(reduction='mean') ``` -reduction 为'sum' + +#### reduction 为 None ```python # PyTorch 写法 -torch.nn.SoftMarginLoss(reduction='sum') +torch.nn.SoftMarginLoss(size_average=True, reduce=False) +torch.nn.SoftMarginLoss(size_average=False, reduce=False) +torch.nn.SoftMarginLoss(reduce=False) # Paddle 写法 -paddle.nn.SoftMarginLoss(reduction='sum') +paddle.nn.SoftMarginLoss(reduction='None') ``` diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.TripletMarginLoss.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.TripletMarginLoss.md index 5042f565e3e..7544fe68da0 100644 --- a/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.TripletMarginLoss.md +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.TripletMarginLoss.md @@ -24,65 +24,37 @@ PyTorch 相比 Paddle 支持更多其他参数,具体如下: | reduction | reduction | 指定应用于输出结果的计算方式。 | ### 转写示例 - - -#### size_average -size_average 为 True +#### reduction 为 sum ```python # PyTorch 写法 -torch.nn.TripletMarginLoss(size_average=True) +torch.nn.TripletMarginLoss(margin=m, size_average=False, reduce=True) +torch.nn.TripletMarginLoss(margin=m, size_average=Flase) # Paddle 写法 -paddle.nn.TripletMarginLoss(reduction='mean') +paddle.nn.TripletMarginLoss(margin=m, reduction='sum') ``` -size_average 为 False +#### reduction 为 mean ```python # PyTorch 写法 -torch.nn.TripletMarginLoss(size_average=False) +torch.nn.TripletMarginLoss(margin=m, size_average=True, reduce=True) +torch.nn.TripletMarginLoss(margin=m, reduce=True) +torch.nn.TripletMarginLoss(margin=m, size_average=True) +torch.nn.TripletMarginLoss(margin=m) # Paddle 写法 -paddle.nn.TripletMarginLoss(reduction='sum') +paddle.nn.TripletMarginLoss(margin=m, reduction='mean') ``` -#### reduce -reduce 为 True -```python -# PyTorch 写法 -torch.nn.TripletMarginLoss(reduce=True) -# Paddle 写法 -paddle.nn.TripletMarginLoss(reduction='sum') -``` -reduce 为 False +#### reduction 为 None ```python # PyTorch 写法 -torch.nn.TripletMarginLoss(reduce=False) +torch.nn.TripletMarginLoss(margin=m, size_average=True, reduce=False) +torch.nn.TripletMarginLoss(margin=m, size_average=False, reduce=False) +torch.nn.TripletMarginLoss(margin=m, reduce=False) # Paddle 写法 -paddle.nn.TripletMarginLoss(reduction='none') +paddle.nn.TripletMarginLoss(margin=m, reduction='None') ``` -#### reduction -reduction 为'none' -```python -# PyTorch 写法 -torch.nn.TripletMarginLoss(reduction='none') -# Paddle 写法 -paddle.nn.TripletMarginLoss(reduction='none') -``` -reduction 为'mean' -```python -# PyTorch 写法 -torch.nn.TripletMarginLoss(reduction='mean') -# Paddle 写法 -paddle.nn.TripletMarginLoss(reduction='mean') -``` -reduction 为'sum' -```python -# PyTorch 写法 -torch.nn.TripletMarginLoss(reduction='sum') - -# Paddle 写法 -paddle.nn.TripletMarginLoss(reduction='sum') -``` From 0ed66605aaa5ce29c357115d847d68860807e88a Mon Sep 17 00:00:00 2001 From: zty-king <17786324919@163.com> Date: Thu, 13 Nov 2025 14:40:05 +0000 Subject: [PATCH 2/2] fix the loss doc --- .../api_difference/torch_more_args/torch.nn.BCELoss.md | 6 +++--- .../torch_more_args/torch.nn.BCEWithLogitsLoss.md | 6 +++--- .../torch_more_args/torch.nn.CosineEmbeddingLoss.md | 6 +++--- .../torch_more_args/torch.nn.CrossEntropyLoss.md | 7 +++---- .../torch_more_args/torch.nn.HingeEmbeddingLoss.md | 7 +++---- .../api_difference/torch_more_args/torch.nn.KLDivLoss.md | 8 +++----- .../api_difference/torch_more_args/torch.nn.L1Loss.md | 4 ++-- .../api_difference/torch_more_args/torch.nn.MSELoss.md | 4 ++-- .../torch_more_args/torch.nn.MarginRankingLoss.md | 4 ++-- .../torch_more_args/torch.nn.MultiLabelMarginLoss.md | 5 ++--- .../torch_more_args/torch.nn.MultiLabelSoftMarginLoss.md | 4 ++-- .../torch_more_args/torch.nn.MultiMarginLoss.md | 4 ++-- .../api_difference/torch_more_args/torch.nn.NLLLoss.md | 4 ++-- .../torch_more_args/torch.nn.PoissonNLLLoss.md | 4 ++-- .../torch_more_args/torch.nn.SmoothL1Loss.md | 4 ++-- .../torch_more_args/torch.nn.SoftMarginLoss.md | 4 ++-- .../torch_more_args/torch.nn.TripletMarginLoss.md | 8 +++----- 17 files changed, 41 insertions(+), 48 deletions(-) diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.BCELoss.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.BCELoss.md index e617c7bcb06..ca85ba07020 100644 --- a/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.BCELoss.md +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.BCELoss.md @@ -29,7 +29,7 @@ PyTorch 相比 Paddle 支持更多其他参数,具体如下: ```python # PyTorch 写法 torch.nn.BCELoss(weight=w, size_average=False, reduce=True) -torch.nn.BCELoss(weight=w, size_average=Flase) +torch.nn.BCELoss(weight=w, size_average=False) # Paddle 写法 paddle.nn.BCELoss(weight=w, reduction='sum') @@ -47,7 +47,7 @@ torch.nn.BCELoss(weight=w) paddle.nn.BCELoss(weight=w, reduction='mean') ``` -#### reduction 为 None +#### reduction 为 none ```python # PyTorch 写法 torch.nn.BCELoss(weight=w, size_average=True, reduce=False) @@ -55,5 +55,5 @@ torch.nn.BCELoss(weight=w, size_average=False, reduce=False) torch.nn.BCELoss(weight=w, reduce=False) # Paddle 写法 -paddle.nn.BCELoss(weight=w, reduction='None') +paddle.nn.BCELoss(weight=w, reduction='none') ``` diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.BCEWithLogitsLoss.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.BCEWithLogitsLoss.md index 996eb50e8ef..15362372b61 100644 --- a/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.BCEWithLogitsLoss.md +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.BCEWithLogitsLoss.md @@ -32,7 +32,7 @@ PyTorch 相比 Paddle 支持更多其他参数,具体如下: ```python # PyTorch 写法 torch.nn.BCEWithLogitsLoss(weight=w, size_average=False, reduce=True) -torch.nn.BCEWithLogitsLoss(weight=w, size_average=Flase) +torch.nn.BCEWithLogitsLoss(weight=w, size_average=False) # Paddle 写法 paddle.nn.BCEWithLogitsLoss(weight=w, reduction='sum') @@ -50,7 +50,7 @@ torch.nn.BCEWithLogitsLoss(weight=w) paddle.nn.BCEWithLogitsLoss(weight=w, reduction='mean') ``` -#### reduction 为 None +#### reduction 为 none ```python # PyTorch 写法 torch.nn.BCEWithLogitsLoss(weight=w, size_average=True, reduce=False) @@ -58,5 +58,5 @@ torch.nn.BCEWithLogitsLoss(weight=w, size_average=False, reduce=False) torch.nn.BCEWithLogitsLoss(weight=w, reduce=False) # Paddle 写法 -paddle.nn.BCEWithLogitsLoss(weight=w, reduction='None') +paddle.nn.BCEWithLogitsLoss(weight=w, reduction='none') ``` diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.CosineEmbeddingLoss.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.CosineEmbeddingLoss.md index c725e37320d..067b0195ca5 100644 --- a/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.CosineEmbeddingLoss.md +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.CosineEmbeddingLoss.md @@ -25,7 +25,7 @@ PyTorch 相比 Paddle 支持更多其他参数,具体如下: ```python # PyTorch 写法 torch.nn.CosineEmbeddingLoss(margin=m, size_average=False, reduce=True) -torch.nn.CosineEmbeddingLoss(margin=m, size_average=Flase) +torch.nn.CosineEmbeddingLoss(margin=m, size_average=False) # Paddle 写法 paddle.nn.CosineEmbeddingLoss(margin=m, reduction='sum') @@ -43,7 +43,7 @@ torch.nn.CosineEmbeddingLoss(margin=m) paddle.nn.CosineEmbeddingLoss(margin=m, reduction='mean') ``` -#### reduction 为 None +#### reduction 为 none ```python # PyTorch 写法 torch.nn.CosineEmbeddingLoss(margin=m, size_average=True, reduce=False) @@ -51,5 +51,5 @@ torch.nn.CosineEmbeddingLoss(margin=m, size_average=False, reduce=False) torch.nn.CosineEmbeddingLoss(margin=m, reduce=False) # Paddle 写法 -paddle.nn.CosineEmbeddingLoss(margin=m, reduction='None') +paddle.nn.CosineEmbeddingLoss(margin=m, reduction='none') ``` diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.CrossEntropyLoss.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.CrossEntropyLoss.md index 4b29abea431..e179ecc0d37 100644 --- a/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.CrossEntropyLoss.md +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.CrossEntropyLoss.md @@ -40,7 +40,7 @@ PyTorch 相比 Paddle 支持更多其他参数,具体如下: ```python # PyTorch 写法 torch.nn.CrossEntropyLoss(weight=w, size_average=False, reduce=True) -torch.nn.CrossEntropyLoss(weight=w, size_average=Flase) +torch.nn.CrossEntropyLoss(weight=w, size_average=False) # Paddle 写法 paddle.nn.CrossEntropyLoss(weight=w, reduction='sum') @@ -58,7 +58,7 @@ torch.nn.CrossEntropyLoss(weight=w) paddle.nn.CrossEntropyLoss(weight=w, reduction='mean') ``` -#### reduction 为 None +#### reduction 为 none ```python # PyTorch 写法 torch.nn.CrossEntropyLoss(weight=w, size_average=True, reduce=False) @@ -66,6 +66,5 @@ torch.nn.CrossEntropyLoss(weight=w, size_average=False, reduce=False) torch.nn.CrossEntropyLoss(weight=w, reduce=False) # Paddle 写法 -paddle.nn.CrossEntropyLoss(weight=w, reduction='None') +paddle.nn.CrossEntropyLoss(weight=w, reduction='none') ``` - diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.HingeEmbeddingLoss.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.HingeEmbeddingLoss.md index f5cbecd141f..6140e6e95e7 100644 --- a/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.HingeEmbeddingLoss.md +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.HingeEmbeddingLoss.md @@ -30,7 +30,7 @@ PyTorch 相比 Paddle 支持更多其他参数,具体如下: ```python # PyTorch 写法 torch.nn.HingeEmbeddingLoss(margin=m, size_average=False, reduce=True) -torch.nn.HingeEmbeddingLoss(margin=m, size_average=Flase) +torch.nn.HingeEmbeddingLoss(margin=m, size_average=False) # Paddle 写法 paddle.nn.HingeEmbeddingLoss(margin=m, reduction='sum') @@ -48,7 +48,7 @@ torch.nn.HingeEmbeddingLoss(margin=m) paddle.nn.HingeEmbeddingLoss(margin=m, reduction='mean') ``` -#### reduction 为 None +#### reduction 为 none ```python # PyTorch 写法 torch.nn.HingeEmbeddingLoss(margin=m, size_average=True, reduce=False) @@ -56,6 +56,5 @@ torch.nn.HingeEmbeddingLoss(margin=m, size_average=False, reduce=False) torch.nn.HingeEmbeddingLoss(margin=m, reduce=False) # Paddle 写法 -paddle.nn.HingeEmbeddingLoss(margin=m, reduction='None') +paddle.nn.HingeEmbeddingLoss(margin=m, reduction='none') ``` - diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.KLDivLoss.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.KLDivLoss.md index 0023da3c1ef..e405f414ca4 100644 --- a/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.KLDivLoss.md +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.KLDivLoss.md @@ -28,7 +28,7 @@ PyTorch 相比 Paddle 支持更多其他参数,具体如下: ```python # PyTorch 写法 torch.nn.KLDivLoss(size_average=False, reduce=True) -torch.nn.KLDivLoss(size_average=Flase) +torch.nn.KLDivLoss(size_average=False) # Paddle 写法 paddle.nn.KLDivLoss(reduction='sum') @@ -46,7 +46,7 @@ torch.nn.KLDivLoss() paddle.nn.KLDivLoss(reduction='mean') ``` -#### reduction 为 None +#### reduction 为 none ```python # PyTorch 写法 torch.nn.KLDivLoss(size_average=True, reduce=False) @@ -54,7 +54,5 @@ torch.nn.KLDivLoss(size_average=False, reduce=False) torch.nn.KLDivLoss(reduce=False) # Paddle 写法 -paddle.nn.KLDivLoss(reduction='None') +paddle.nn.KLDivLoss(reduction='none') ``` - - diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.L1Loss.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.L1Loss.md index e60bfb78564..d23c154ea27 100644 --- a/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.L1Loss.md +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.L1Loss.md @@ -44,7 +44,7 @@ torch.nn.L1Loss() paddle.nn.L1Loss(reduction='mean') ``` -#### reduction 为 None +#### reduction 为 none ```python # PyTorch 写法 torch.nn.L1Loss(size_average=True, reduce=False) @@ -52,5 +52,5 @@ torch.nn.L1Loss(size_average=False, reduce=False) torch.nn.L1Loss(reduce=False) # Paddle 写法 -paddle.nn.L1Loss(reduction='None') +paddle.nn.L1Loss(reduction='none') ``` diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.MSELoss.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.MSELoss.md index 9b9626e6917..fb584dd4b58 100644 --- a/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.MSELoss.md +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.MSELoss.md @@ -43,7 +43,7 @@ torch.nn.MSELoss() paddle.nn.MSELoss(reduction='mean') ``` -#### reduction 为 None +#### reduction 为 none ```python # PyTorch 写法 torch.nn.MSELoss(size_average=True, reduce=False) @@ -51,5 +51,5 @@ torch.nn.MSELoss(size_average=False, reduce=False) torch.nn.MSELoss(reduce=False) # Paddle 写法 -paddle.nn.MSELoss(reduction='None') +paddle.nn.MSELoss(reduction='none') ``` diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.MarginRankingLoss.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.MarginRankingLoss.md index 74af581732b..bbcd824702b 100644 --- a/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.MarginRankingLoss.md +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.MarginRankingLoss.md @@ -48,7 +48,7 @@ torch.nn.MarginRankingLoss(margin=m) paddle.nn.MarginRankingLoss(margin=m, reduction='mean') ``` -#### reduction 为 None +#### reduction 为 none ```python # PyTorch 写法 torch.nn.MarginRankingLoss(margin=m, size_average=True, reduce=False) @@ -56,5 +56,5 @@ torch.nn.MarginRankingLoss(margin=m, size_average=False, reduce=False) torch.nn.MarginRankingLoss(margin=m, reduce=False) # Paddle 写法 -paddle.nn.MarginRankingLoss(margin=m, reduction='None') +paddle.nn.MarginRankingLoss(margin=m, reduction='none') ``` diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.MultiLabelMarginLoss.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.MultiLabelMarginLoss.md index 0124ba24252..86ef1fb94e4 100644 --- a/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.MultiLabelMarginLoss.md +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.MultiLabelMarginLoss.md @@ -42,7 +42,7 @@ torch.nn.MultiLabelMarginLoss() paddle.nn.MultiLabelMarginLoss(reduction='mean') ``` -#### reduction 为 None +#### reduction 为 none ```python # PyTorch 写法 torch.nn.MultiLabelMarginLoss(size_average=True, reduce=False) @@ -50,6 +50,5 @@ torch.nn.MultiLabelMarginLoss(size_average=False, reduce=False) torch.nn.MultiLabelMarginLoss(reduce=False) # Paddle 写法 -paddle.nn.MultiLabelMarginLoss(reduction='None') +paddle.nn.MultiLabelMarginLoss(reduction='none') ``` - diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.MultiLabelSoftMarginLoss.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.MultiLabelSoftMarginLoss.md index ff04ebc468c..ece9c5be617 100644 --- a/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.MultiLabelSoftMarginLoss.md +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.MultiLabelSoftMarginLoss.md @@ -43,7 +43,7 @@ torch.nn.MultiLabelSoftMarginLoss(weight=w) paddle.nn.MultiLabelSoftMarginLoss(weight=w, reduction='mean') ``` -#### reduction 为 None +#### reduction 为 none ```python # PyTorch 写法 torch.nn.MultiLabelSoftMarginLoss(weight=w, size_average=True, reduce=False) @@ -51,5 +51,5 @@ torch.nn.MultiLabelSoftMarginLoss(weight=w, size_average=False, reduce=False) torch.nn.MultiLabelSoftMarginLoss(weight=w, reduce=False) # Paddle 写法 -paddle.nn.MultiLabelSoftMarginLoss(weight=w, reduction='None') +paddle.nn.MultiLabelSoftMarginLoss(weight=w, reduction='none') ``` diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.MultiMarginLoss.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.MultiMarginLoss.md index 828e79aeb93..854bae2e7d8 100644 --- a/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.MultiMarginLoss.md +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.MultiMarginLoss.md @@ -45,7 +45,7 @@ torch.nn.MultiMarginLoss(p=1, margin=1.0, weight=w) paddle.nn.MultiMarginLoss(p=1, margin=1.0, weight=w, reduction='mean') ``` -#### reduction 为 None +#### reduction 为 none ```python # PyTorch 写法 torch.nn.MultiMarginLoss(p=1, margin=1.0, weight=w, size_average=True, reduce=False) @@ -53,5 +53,5 @@ torch.nn.MultiMarginLoss(p=1, margin=1.0, weight=w, size_average=False, reduce=F torch.nn.MultiMarginLoss(p=1, margin=1.0, weight=w, reduce=False) # Paddle 写法 -paddle.nn.MultiMarginLoss(p=1, margin=1.0, weight=w, reduction='None') +paddle.nn.MultiMarginLoss(p=1, margin=1.0, weight=w, reduction='none') ``` diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.NLLLoss.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.NLLLoss.md index 0614396b206..fb0dc8fd45d 100644 --- a/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.NLLLoss.md +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.NLLLoss.md @@ -51,7 +51,7 @@ torch.nn.NLLLoss(weight=w, ignore_index=-100) paddle.nn.NLLLoss(weight=w, ignore_index=-100, reduction='mean') ``` -#### reduction 为 None +#### reduction 为 none ```python # PyTorch 写法 torch.nn.NLLLoss(weight=w, ignore_index=-100, size_average=True, reduce=False) @@ -59,5 +59,5 @@ torch.nn.NLLLoss(weight=w, ignore_index=-100, size_average=False, reduce=False) torch.nn.NLLLoss(weight=w, ignore_index=-100, reduce=False) # Paddle 写法 -paddle.nn.NLLLoss(weight=w, ignore_index=-100, reduction='None') +paddle.nn.NLLLoss(weight=w, ignore_index=-100, reduction='none') ``` diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.PoissonNLLLoss.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.PoissonNLLLoss.md index a05011b5e07..629e1a2af52 100644 --- a/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.PoissonNLLLoss.md +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.PoissonNLLLoss.md @@ -45,7 +45,7 @@ torch.nn.PoissonNLLLoss(log_input=True, full=False, eps=1e-8) paddle.nn.PoissonNLLLoss(log_input=True, full=False, epsilon=1e-8, reduction='mean') ``` -#### reduction 为 None +#### reduction 为 none ```python # PyTorch 写法 torch.nn.PoissonNLLLoss(log_input=True, full=False, eps=1e-8, size_average=True, reduce=False) @@ -53,5 +53,5 @@ torch.nn.PoissonNLLLoss(log_input=True, full=False, eps=1e-8, size_average=False torch.nn.PoissonNLLLoss(log_input=True, full=False, eps=1e-8, reduce=False) # Paddle 写法 -paddle.nn.PoissonNLLLoss(log_input=True, full=False, epsilon=1e-8, reduction='None') +paddle.nn.PoissonNLLLoss(log_input=True, full=False, epsilon=1e-8, reduction='none') ``` diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.SmoothL1Loss.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.SmoothL1Loss.md index 596979cb9fa..6294ea4e188 100644 --- a/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.SmoothL1Loss.md +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.SmoothL1Loss.md @@ -49,7 +49,7 @@ torch.nn.SmoothL1Loss() paddle.nn.SmoothL1Loss(reduction='mean',is_huber=False) ``` -#### reduction 为 None +#### reduction 为 none ```python # PyTorch 写法 torch.nn.SmoothL1Loss(size_average=True, reduce=False) @@ -57,5 +57,5 @@ torch.nn.SmoothL1Loss(size_average=False, reduce=False) torch.nn.SmoothL1Loss(reduce=False) # Paddle 写法 -paddle.nn.SmoothL1Loss(reduction='None',is_huber=False) +paddle.nn.SmoothL1Loss(reduction='none',is_huber=False) ``` diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.SoftMarginLoss.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.SoftMarginLoss.md index 99937b4e3d7..9cfd44819a6 100644 --- a/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.SoftMarginLoss.md +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.SoftMarginLoss.md @@ -45,7 +45,7 @@ torch.nn.SoftMarginLoss() paddle.nn.SoftMarginLoss(reduction='mean') ``` -#### reduction 为 None +#### reduction 为 none ```python # PyTorch 写法 torch.nn.SoftMarginLoss(size_average=True, reduce=False) @@ -53,5 +53,5 @@ torch.nn.SoftMarginLoss(size_average=False, reduce=False) torch.nn.SoftMarginLoss(reduce=False) # Paddle 写法 -paddle.nn.SoftMarginLoss(reduction='None') +paddle.nn.SoftMarginLoss(reduction='none') ``` diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.TripletMarginLoss.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.TripletMarginLoss.md index 7544fe68da0..5ff51e9c7df 100644 --- a/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.TripletMarginLoss.md +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.TripletMarginLoss.md @@ -28,7 +28,7 @@ PyTorch 相比 Paddle 支持更多其他参数,具体如下: ```python # PyTorch 写法 torch.nn.TripletMarginLoss(margin=m, size_average=False, reduce=True) -torch.nn.TripletMarginLoss(margin=m, size_average=Flase) +torch.nn.TripletMarginLoss(margin=m, size_average=False) # Paddle 写法 paddle.nn.TripletMarginLoss(margin=m, reduction='sum') @@ -46,7 +46,7 @@ torch.nn.TripletMarginLoss(margin=m) paddle.nn.TripletMarginLoss(margin=m, reduction='mean') ``` -#### reduction 为 None +#### reduction 为 none ```python # PyTorch 写法 torch.nn.TripletMarginLoss(margin=m, size_average=True, reduce=False) @@ -54,7 +54,5 @@ torch.nn.TripletMarginLoss(margin=m, size_average=False, reduce=False) torch.nn.TripletMarginLoss(margin=m, reduce=False) # Paddle 写法 -paddle.nn.TripletMarginLoss(margin=m, reduction='None') +paddle.nn.TripletMarginLoss(margin=m, reduction='none') ``` - -