Skip to content
class

VectorQuantizerOutput

extendsNamedTuple
VectorQuantizerOutput()

What VectorQuantizer returns.

Attributes

quantizedTensor
The quantised field, same shape as the input. Numerically equal to the selected codebook entries, but differentiable with respect to the input via the straight-through estimator.
indicesTensor
Selected entry per position — the input's shape with the trailing feature axis dropped, int64 dtype.
codebook_lossTensor
Scalar ∥sg[x]−e∥22\| \mathrm{sg}[x] - e \|_2^2, which trains the codebook and is detached from the input.
commitment_lossTensor
Scalar ∥x−sg[e]∥22\| x - \mathrm{sg}[e] \|_2^2, which trains the input's producer and is detached from the codebook. Reported unweighted — apply commitment_cost when summing the terms.
perplexityTensor
Scalar exp⁡(−∑kpklog⁡pk)\exp(-\sum_k p_k \log p_k) over the batch's usage histogram, in [1, num_embeddings]. A value falling toward 1 means the codebook is collapsing to a few live entries.

Used by 1