MCPcopy Create free account
hub / github.com/3DAnimals/3DAnimals / length

Function length

model/render/util.py:28–29  ·  view source on GitHub ↗
(x: torch.Tensor, eps: float =1e-20)

Source from the content-addressed store, hash-verified

26 return 2*dot(x, n)*n - x
27
28def length(x: torch.Tensor, eps: float =1e-20) -> torch.Tensor:
29 return torch.sqrt(torch.clamp(dot(x,x), min=eps)) # Clamp to avoid nan gradients because grad(sqrt(0)) = NaN
30
31def safe_normalize(x: torch.Tensor, eps: float =1e-20) -> torch.Tensor:
32 return x / length(x, eps)

Callers 1

safe_normalizeFunction · 0.85

Calls 1

dotFunction · 0.70

Tested by

no test coverage detected