MCPcopy Create free account
hub / github.com/Standard-Intelligence/hertz-dev / bound

Method bound

ioblocks.py:209–214  ·  view source on GitHub ↗

Bound `z`, an array of shape (..., d).

(self, z, eps: float = 1e-3)

Source from the content-addressed store, hash-verified

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. """

Callers 1

quantizeMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected