Inverse function of sigmoid. Args: x (Tensor): The tensor to do the inverse. eps (float): EPS avoid numerical overflow. Defaults 1e-5. Returns: Tensor: The x has passed the inverse function of sigmoid, has same
(x, eps=1e-5)
| 32 | def inverse_sigmoid(x, eps=1e-5): |
| 33 | """Inverse function of sigmoid. |
| 34 | Args: |
| 35 | x (Tensor): The tensor to do the |
| 36 | inverse. |
| 37 | eps (float): EPS avoid numerical |
| 38 | overflow. Defaults 1e-5. |
| 39 | Returns: |
| 40 | Tensor: The x has passed the inverse |
| 41 | function of sigmoid, has same |
| 42 | shape with input. |
| 43 | """ |
| 44 | x = x.clamp(min=0, max=1) |
| 45 | x1 = x.clamp(min=eps) |
| 46 | x2 = (1 - x).clamp(min=eps) |
| 47 | return torch.log(x1 / x2) |
| 48 | |
| 49 | |
| 50 | @TRANSFORMER_LAYER_SEQUENCE.register_module() |
| 51 | class DetectionTransformerDecoder(TransformerLayerSequence): |
| 52 | """Implements the decoder in DETR3D transformer. |