MCPcopy Create free account
hub / github.com/apple/ml-sharp / inverse_softplus

Function inverse_softplus

src/sharp/utils/math.py:62–67  ·  view source on GitHub ↗

Compute inverse softplus.

(tensor: torch.Tensor, eps: float = 1e-06)

Source from the content-addressed store, hash-verified

60
61
62def inverse_softplus(tensor: torch.Tensor, eps: float = 1e-06) -> torch.Tensor:
63 """Compute inverse softplus."""
64 tensor = tensor.clamp_min(eps)
65 sigmoid = torch.sigmoid(-tensor)
66 exp = sigmoid / (1.0 - sigmoid)
67 return tensor + torch.log(-exp + 1.0)
68
69
70# The first value describes the threshold from where clamping will be applied, while

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected