MCPcopy Create free account
hub / github.com/OpenMeshLab/MeshXL / huber_loss

Function huber_loss

utils/misc.py:25–36  ·  view source on GitHub ↗

Ref: https://github.com/charlesq34/frustum-pointnets/blob/master/models/model_util.py x = error = pred - gt or dist(pred,gt) 0.5 * |x|^2 if |x|<=d 0.5 * d^2 + d * (|x|-d) if |x|>d

(error, delta=1.0)

Source from the content-addressed store, hash-verified

23
24
25def huber_loss(error, delta=1.0):
26 """
27 Ref: https://github.com/charlesq34/frustum-pointnets/blob/master/models/model_util.py
28 x = error = pred - gt or dist(pred,gt)
29 0.5 * |x|^2 if |x|<=d
30 0.5 * d^2 + d * (|x|-d) if |x|>d
31 """
32 abs_error = torch.abs(error)
33 quadratic = torch.clamp(abs_error, max=delta)
34 linear = abs_error - quadratic
35 loss = 0.5 * quadratic ** 2 + delta * linear
36 return loss
37
38
39# From https://github.com/facebookresearch/detr/blob/master/util/misc.py

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected