Bound `z`, an array of shape (..., d).
(self, z, eps: float = 1e-3)
| 207 | return self.indices_to_codes(latent) |
| 208 | |
| 209 | def bound(self, z, eps: float = 1e-3): |
| 210 | """ Bound `z`, an array of shape (..., d). """ |
| 211 | half_l = (self._levels - 1) * (1 + eps) / 2 |
| 212 | offset = T.where(self._levels % 2 == 0, 0.5, 0.0) |
| 213 | shift = (offset / half_l).atanh() |
| 214 | return (z + shift).tanh() * half_l - offset |
| 215 | |
| 216 | def quantize(self, z): |
| 217 | """ Quantizes z, returns quantized zhat, same shape as z. """ |