torch.nn.functional.l1_loss#
- torch.nn.functional.l1_loss(input, target, size_average=None, reduce=None, reduction='mean', weight=None)[source]#
计算 L1 损失,可选加权。
计算元素级绝对值差的平均值的函数。
有关详细信息,请参阅
L1Loss
。- 参数
input (Tensor) – 预测值。
target (Tensor) – 真值。
size_average (bool, optional) – 已弃用 (参见
reduction
)。reduce (bool, optional) – 已弃用 (参见
reduction
)。reduction (str, optional) – 指定要应用于输出的规约:‘none’ | ‘mean’ | ‘sum’。‘mean’:取输出的平均值。‘sum’:将对输出进行求和。‘none’:不应用任何规约。默认值:‘mean’。
weight (Tensor, 可选) – 每个样本的权重。默认值:None。
- 返回
L1 损失(可选加权)。
- 返回类型