Skip to content

Commit af576e5

Browse files
committed
per sample entropy needs to account for variable length sequences as well
1 parent 7984467 commit af576e5

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
setup(
44
name = 'vector_quantize_pytorch',
55
packages = find_packages(),
6-
version = '1.12.5',
6+
version = '1.12.6',
77
license='MIT',
88
description = 'Vector Quantization - Pytorch',
99
long_description_content_type = 'text/markdown',

vector_quantize_pytorch/lookup_free_quantization.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,13 +215,13 @@ def forward(
215215

216216
prob = (-distance * inv_temperature).softmax(dim = -1)
217217

218-
per_sample_entropy = entropy(prob).mean()
219-
220218
# account for mask
221219

222220
if exists(mask):
223221
prob = prob[mask]
224222

223+
per_sample_entropy = entropy(prob).mean()
224+
225225
# distribution over all available tokens in the batch
226226

227227
avg_prob = reduce(prob, '... c d -> c d', 'mean')

0 commit comments

Comments
 (0)