Return constants for scale activation function.
(max_scale: float, min_scale: float)
| 19 | |
| 20 | |
| 21 | def _get_scale_activation_constant(max_scale: float, min_scale: float) -> tuple[float, float]: |
| 22 | """Return constants for scale activation function.""" |
| 23 | # To ensure for delta = 0, the value of scale_factor is 1 and the gradient is 1. |
| 24 | constant_a = (max_scale - min_scale) / (1 - min_scale) / (max_scale - 1) |
| 25 | constant_b = math_utils.inverse_sigmoid( |
| 26 | torch.tensor((1.0 - min_scale) / (max_scale - min_scale)) |
| 27 | ).item() |
| 28 | return constant_a, constant_b |
| 29 | |
| 30 | |
| 31 | class GaussianComposer(nn.Module): |