Compute inverse softplus.
(tensor: torch.Tensor, eps: float = 1e-06)
| 60 | |
| 61 | |
| 62 | def 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 |
nothing calls this directly
no outgoing calls
no test coverage detected