INNER CODE UNIT · Python

aux_loss

lucidrains/vector-quantize-pytorch · vector_quantize_pytorch/evo_lookup_free_quantization.py:81

        quantized, indices, aux_loss = self.lfq(latents, **kwargs)

        if is_2d:
            quantized = rearrange(quantized, 'b 1 d -> b d')
            indices = rearrange(indices, 'b 1 ... -> b ...')

        reconstructed = self.decoder(quantized)
        return Return(reconstructed, indices, aux_loss)

    @torch.no_grad()
    def encode(self, x, return_signs = False):
        with temp_eval(self):
            latents = self.encoder(x)
            is_2d = latents.ndim == 2

            if is_2d:
                latents = rearrange(latents, 'b d -> b 1 d')

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…