MCPcopy Create free account
hub / github.com/dcharatan/flowmap / MappingHuber

Class MappingHuber

flowmap/loss/mapping/mapping_huber.py:18–34  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16
17
18class MappingHuber(Mapping[MappingHuberCfg]):
19 def forward_undistorted(
20 self,
21 delta: Float[Tensor, "*batch 2"],
22 ) -> Float[Tensor, " *batch"]:
23 norm = delta.norm(dim=-1)
24
25 mapped = F.huber_loss(
26 norm,
27 torch.zeros_like(norm),
28 reduction="none",
29 delta=self.cfg.delta,
30 )
31
32 # Divide by the delta so that the gradient magnitude in the linear region
33 # matches that of a regular L1 loss.
34 return mapped / self.cfg.delta

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected