MCPcopy Create free account
hub / github.com/Physical-Intelligence/openpi / encode

Method encode

src/openpi/models/utils/fsq_tokenizer.py:93–103  ·  view source on GitHub ↗
(self, inputs: jnp.ndarray)

Source from the content-addressed store, hash-verified

91 return tokens, output
92
93 def encode(self, inputs: jnp.ndarray) -> tuple[jnp.ndarray, jnp.ndarray]:
94 bases = jnp.array(self.bins_per_dim)
95
96 x = self.proj_down(inputs)
97 z = jnp.tanh(x)
98
99 # Quantize
100 digits = jnp.round((z + 1) * (bases - 1) / 2).astype(jnp.int32)
101 tokens = self.undigitize(digits)
102
103 return tokens, z
104
105 def decode(self, tokens: jnp.ndarray, z_grad: jax.Array | None = None) -> jnp.ndarray:
106 bases = jnp.array(self.bins_per_dim)

Callers 2

__call__Method · 0.95
tokenizeMethod · 0.45

Calls 1

undigitizeMethod · 0.95

Tested by

no test coverage detected