Skip to content

Fix NameError in EMAVectorQuantizer.__init__#267

Open
Mr-Neutr0n wants to merge 1 commit intoCompVis:masterfrom
Mr-Neutr0n:fix/ema-vectorquantizer-init-params
Open

Fix NameError in EMAVectorQuantizer.__init__#267
Mr-Neutr0n wants to merge 1 commit intoCompVis:masterfrom
Mr-Neutr0n:fix/ema-vectorquantizer-init-params

Conversation

@Mr-Neutr0n
Copy link

Summary

EMAVectorQuantizer.__init__ references two undefined variables — codebook_dim and num_tokens — instead of the actual constructor parameters embedding_dim and n_embed. This causes an immediate NameError when instantiating EMAVectorQuantizer, making EMA-based vector quantization (and the EMAVQ model) completely unusable.

Change

  • self.codebook_dim = codebook_dimself.codebook_dim = embedding_dim
  • self.num_tokens = num_tokensself.num_tokens = n_embed

How to reproduce

from taming.modules.vqvae.quantize import EMAVectorQuantizer
# This raises: NameError: name 'codebook_dim' is not defined
eq = EMAVectorQuantizer(n_embed=512, embedding_dim=256, beta=0.25)

After the fix, the constructor correctly assigns from its own parameters and the class works as intended.

EMAVectorQuantizer.__init__ references `codebook_dim` and `num_tokens`,
which are not defined in the constructor's scope. The correct parameter
names are `embedding_dim` and `n_embed` respectively. This causes an
immediate NameError when instantiating EMAVectorQuantizer (and by
extension, the EMAVQ model), making EMA-based vector quantization
completely unusable.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant