Skip to content

Commit 43595a8

Browse files
committed
allow for access to codebook with property method
1 parent 381d574 commit 43595a8

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
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 = '0.2.1',
6+
version = '0.2.2',
77
license='MIT',
88
description = 'Vector Quantization - Pytorch',
99
author = 'Phil Wang',

vector_quantize_pytorch/vector_quantize_pytorch.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ def __init__(
3838
self.register_buffer('cluster_size', torch.zeros(n_embed))
3939
self.register_buffer('embed_avg', embed.clone())
4040

41+
@property
42+
def codebook(self):
43+
return self.embed.transpose(0, 1)
44+
4145
def forward(self, input):
4246
dtype = input.dtype
4347
flatten = input.reshape(-1, self.dim)

0 commit comments

Comments
 (0)