Round with straight through gradients.
(z: Tensor)
| 125 | # tensor helpers |
| 126 | |
| 127 | def round_ste(z: Tensor) -> Tensor: |
| 128 | """Round with straight through gradients.""" |
| 129 | zhat = z.round() |
| 130 | return z + (zhat - z).detach() |
| 131 | |
| 132 | # main class |
| 133 | # lucidrains fsq |