lucidrains / vector-quantize-pytorch

Vector (and Scalar) Quantization, in Pytorch
MIT License
2.65k stars 215 forks source link

What's the difference of the distance calculation between the master and fix-lfq-distance branch? #146

Closed xuzq23 closed 4 months ago

xuzq23 commented 4 months ago

Hello, @lucidrains, I have some questions, I see that there are two different distance calculation methods in the file lookup_free_quantization.py, for branch master, line 337, distance = -2 * einsum('... i d, j d -> ... i j', original_input, codebook) for branch fix-lfq-distance, line 229, distance = euclidean_distance_squared(original_input, self.codebook) My questions are: 1.Why do you take the first formulation while euclidean_distance_squared is adopted in many projects? 2.Would they result in different peformance? Thanks.