Smooth given values. Args: value: Value to smooth. label_smoothing: smoothing constant. Returns: Smoothed values.
( value: torch.Tensor, label_smoothing: Union[float, torch.Tensor] )
| 12 | |
| 13 | |
| 14 | def _smooth( |
| 15 | value: torch.Tensor, label_smoothing: Union[float, torch.Tensor] |
| 16 | ) -> Union[float, torch.Tensor]: |
| 17 | """ |
| 18 | Smooth given values. |
| 19 | Args: |
| 20 | value: Value to smooth. |
| 21 | label_smoothing: smoothing constant. |
| 22 | Returns: Smoothed values. |
| 23 | """ |
| 24 | return value * (1.0 - label_smoothing) + 0.5 * label_smoothing |
| 25 | |
| 26 | |
| 27 | def _binary_cross_entropy_with_clipping( |