Apply hard sigmoid with pushback. For compatibility reasons, we follow the default PyTorch implementation with a default slope of 1/6: https://pytorch.org/docs/stable/generated/torch.nn.Hardsigmoid.html
(x: torch.Tensor, slope: float = 1.0 / 6.0)
| 168 | |
| 169 | |
| 170 | def hard_sigmoid_with_pushback(x: torch.Tensor, slope: float = 1.0 / 6.0) -> torch.Tensor: |
| 171 | """Apply hard sigmoid with pushback. |
| 172 | |
| 173 | For compatibility reasons, we follow the default PyTorch implementation with a |
| 174 | default slope of 1/6: |
| 175 | |
| 176 | https://pytorch.org/docs/stable/generated/torch.nn.Hardsigmoid.html |
| 177 | """ |
| 178 | return clamp_with_pushback(slope * x + 0.5, min=0.0, max=1.0) |
| 179 | |
| 180 | |
| 181 | def relu_with_pushback(x: torch.Tensor) -> torch.Tensor: |
nothing calls this directly
no test coverage detected