vector-quantize-pytorch 1.22.7__tar.gz → 1.22.9__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. {vector_quantize_pytorch-1.22.7 → vector_quantize_pytorch-1.22.9}/PKG-INFO +1 -1
  2. {vector_quantize_pytorch-1.22.7 → vector_quantize_pytorch-1.22.9}/pyproject.toml +1 -1
  3. {vector_quantize_pytorch-1.22.7 → vector_quantize_pytorch-1.22.9}/vector_quantize_pytorch/finite_scalar_quantization.py +4 -7
  4. {vector_quantize_pytorch-1.22.7 → vector_quantize_pytorch-1.22.9}/.github/workflows/build.yml +0 -0
  5. {vector_quantize_pytorch-1.22.7 → vector_quantize_pytorch-1.22.9}/.github/workflows/python-publish.yml +0 -0
  6. {vector_quantize_pytorch-1.22.7 → vector_quantize_pytorch-1.22.9}/.github/workflows/test.yml +0 -0
  7. {vector_quantize_pytorch-1.22.7 → vector_quantize_pytorch-1.22.9}/.gitignore +0 -0
  8. {vector_quantize_pytorch-1.22.7 → vector_quantize_pytorch-1.22.9}/LICENSE +0 -0
  9. {vector_quantize_pytorch-1.22.7 → vector_quantize_pytorch-1.22.9}/README.md +0 -0
  10. {vector_quantize_pytorch-1.22.7 → vector_quantize_pytorch-1.22.9}/examples/autoencoder.py +0 -0
  11. {vector_quantize_pytorch-1.22.7 → vector_quantize_pytorch-1.22.9}/examples/autoencoder_fsq.py +0 -0
  12. {vector_quantize_pytorch-1.22.7 → vector_quantize_pytorch-1.22.9}/examples/autoencoder_lfq.py +0 -0
  13. {vector_quantize_pytorch-1.22.7 → vector_quantize_pytorch-1.22.9}/examples/autoencoder_sim_vq.py +0 -0
  14. {vector_quantize_pytorch-1.22.7 → vector_quantize_pytorch-1.22.9}/images/fsq.png +0 -0
  15. {vector_quantize_pytorch-1.22.7 → vector_quantize_pytorch-1.22.9}/images/lfq.png +0 -0
  16. {vector_quantize_pytorch-1.22.7 → vector_quantize_pytorch-1.22.9}/images/simvq.png +0 -0
  17. {vector_quantize_pytorch-1.22.7 → vector_quantize_pytorch-1.22.9}/images/vq.png +0 -0
  18. {vector_quantize_pytorch-1.22.7 → vector_quantize_pytorch-1.22.9}/ruff.toml +0 -0
  19. {vector_quantize_pytorch-1.22.7 → vector_quantize_pytorch-1.22.9}/tests/test_latent_quantization.py +0 -0
  20. {vector_quantize_pytorch-1.22.7 → vector_quantize_pytorch-1.22.9}/tests/test_lfq.py +0 -0
  21. {vector_quantize_pytorch-1.22.7 → vector_quantize_pytorch-1.22.9}/tests/test_readme.py +0 -0
  22. {vector_quantize_pytorch-1.22.7 → vector_quantize_pytorch-1.22.9}/vector_quantize_pytorch/__init__.py +0 -0
  23. {vector_quantize_pytorch-1.22.7 → vector_quantize_pytorch-1.22.9}/vector_quantize_pytorch/latent_quantization.py +0 -0
  24. {vector_quantize_pytorch-1.22.7 → vector_quantize_pytorch-1.22.9}/vector_quantize_pytorch/lookup_free_quantization.py +0 -0
  25. {vector_quantize_pytorch-1.22.7 → vector_quantize_pytorch-1.22.9}/vector_quantize_pytorch/random_projection_quantizer.py +0 -0
  26. {vector_quantize_pytorch-1.22.7 → vector_quantize_pytorch-1.22.9}/vector_quantize_pytorch/residual_fsq.py +0 -0
  27. {vector_quantize_pytorch-1.22.7 → vector_quantize_pytorch-1.22.9}/vector_quantize_pytorch/residual_lfq.py +0 -0
  28. {vector_quantize_pytorch-1.22.7 → vector_quantize_pytorch-1.22.9}/vector_quantize_pytorch/residual_sim_vq.py +0 -0
  29. {vector_quantize_pytorch-1.22.7 → vector_quantize_pytorch-1.22.9}/vector_quantize_pytorch/residual_vq.py +0 -0
  30. {vector_quantize_pytorch-1.22.7 → vector_quantize_pytorch-1.22.9}/vector_quantize_pytorch/sim_vq.py +0 -0
  31. {vector_quantize_pytorch-1.22.7 → vector_quantize_pytorch-1.22.9}/vector_quantize_pytorch/utils.py +0 -0
  32. {vector_quantize_pytorch-1.22.7 → vector_quantize_pytorch-1.22.9}/vector_quantize_pytorch/vector_quantize_pytorch.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: vector-quantize-pytorch
3
- Version: 1.22.7
3
+ Version: 1.22.9
4
4
  Summary: Vector Quantization - Pytorch
5
5
  Project-URL: Homepage, https://pypi.org/project/vector-quantize-pytorch/
6
6
  Project-URL: Repository, https://github.com/lucidrains/vector-quantizer-pytorch
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "vector-quantize-pytorch"
3
- version = "1.22.7"
3
+ version = "1.22.9"
4
4
  description = "Vector Quantization - Pytorch"
5
5
  authors = [
6
6
  { name = "Phil Wang", email = "lucidrains@gmail.com" }
@@ -137,22 +137,19 @@ class FSQ(Module):
137
137
 
138
138
  def quantize(self, z):
139
139
  """ Quantizes z, returns quantized zhat, same shape as z. """
140
+
140
141
  shape, device, noise_dropout, preserve_symmetry, half_width = z.shape[0], z.device, self.noise_dropout, self.preserve_symmetry, (self._levels // 2)
142
+ bound_fn = self.symmetry_preserving_bound if preserve_symmetry else self.bound
141
143
 
142
144
  # determine where to add a random offset elementwise
143
145
  # if using noise dropout
144
146
 
145
147
  if self.training and noise_dropout > 0.:
146
148
  offset_mask = torch.bernoulli(torch.full_like(z, noise_dropout)).bool()
147
- offset = (torch.rand_like(z) - 0.5) / half_width
149
+ offset = torch.rand_like(z) - 0.5
148
150
  z = torch.where(offset_mask, z + offset, z)
149
151
 
150
- if preserve_symmetry:
151
- quantized = round_ste(self.symmetry_preserving_bound(z)) / half_width
152
- else:
153
- quantized = round_ste(self.bound(z)) / half_width
154
-
155
- return quantized
152
+ return round_ste(bound_fn(z)) / half_width
156
153
 
157
154
  def _scale_and_shift(self, zhat_normalized):
158
155
  half_width = self._levels // 2