[torch 参数更多 ]torch.nn.SmoothL1Loss

torch.nn.SmoothL1Loss

torch.nn.SmoothL1Loss(size_average=None,
                      reduce=None,
                      reduction='mean',
                      beta=1.0)

paddle.nn.SmoothL1Loss

paddle.nn.SmoothL1Loss(reduction='mean',
                       delta=1.0,
                       name=None)

Pytorch 相比 Paddle 支持更多其他参数,具体如下:

参数映射

| PyTorch | PaddlePaddle | 备注 | | ————- | ———— | —————————————————— | | size_average | - | PyTorch 已弃用, Paddle 无此参数,需要转写。 | | reduce | - | PyTorch 已弃用, Paddle 无此参数,需要转写。 | | reduction | reduction | 表示应用于输出结果的计算方式。 | | beta | delta | SmoothL1Loss 损失的阈值参数,beta 不为 1.0 时 Paddle 不支持,暂无转写方式。 |

转写示例

size_average

# Paddle 写法
torch.nn.SmoothL1Loss(size_average=True)

# Paddle 写法
paddle.nn.SmoothL1Loss(reduction='mean')

size_average

size_average 为 True

# Pytorch 写法
torch.nn.SmoothL1Loss(size_average=True)

# Paddle 写法
paddle.nn.SmoothL1Loss(reduction='mean')

size_average 为 False

# Pytorch 写法
torch.nn.SmoothL1Loss(size_average=False)

# Paddle 写法
paddle.nn.SmoothL1Loss(reduction='sum')

reduce

reduce 为 True

# Pytorch 写法
torch.nn.SmoothL1Loss(reduce=True)

# Paddle 写法
paddle.nn.SmoothL1Loss(reduction='mean')

reduce 为 False

# Pytorch 写法
torch.nn.SmoothL1Loss(reduce=False)

# Paddle 写法
paddle.nn.SmoothL1Loss(reduction='none')

reduction

reduction 为’none’

# Pytorch 写法
torch.nn.SmoothL1Loss(reduction='none')

# Paddle 写法
paddle.nn.SmoothL1Loss(reduction='none')

reduction 为’mean’

# Pytorch 写法
torch.nn.SmoothL1Loss(reduction='mean')

# Paddle 写法
paddle.nn.SmoothL1Loss(reduction='mean')

reduction 为’sum’

# Pytorch 写法
torch.nn.SmoothL1Loss(reduction='sum')

# Paddle 写法
paddle.nn.SmoothL1Loss(reduction='sum')