Quantizes z, returns quantized zhat, same shape as z.
(self, z)
| 214 | return (z + shift).tanh() * half_l - offset |
| 215 | |
| 216 | def quantize(self, z): |
| 217 | """ Quantizes z, returns quantized zhat, same shape as z. """ |
| 218 | quantized = round_ste(self.bound(z)) |
| 219 | half_width = self._levels // 2 # Renormalize to [-1, 1]. |
| 220 | return quantized / half_width |
| 221 | |
| 222 | def _scale_and_shift(self, zhat_normalized): |
| 223 | half_width = self._levels // 2 |