vector-quantize-pytorch icon indicating copy to clipboard operation
vector-quantize-pytorch copied to clipboard

DDP: RuntimeError: shape mismatch: value tensor of shape [535, 256] cannot be broadcast to indexing result of shape [537, 256]

Open forwiat opened this issue 1 year ago • 3 comments
trafficstars

hi @lucidrains I found the same error #142 this is my code self.vq = VectorQuantize( dim=in_channels, codebook_size=codebook_size, codebook_dim=codebook_dim, threshold_ema_dead_code=threshold_ema_dead_code, kmeans_init=False, )

forwiat avatar Nov 06 '24 03:11 forwiat

ERROR info: File "vector_quantize_pytorch/vector_quantize_pytorch.py", line 529, in forward self.expire_codes_(x) File "vector_quantize_pytorch/vector_quantize_pytorch.py", line 458, in expire_codes_ self.replace(batch_samples, batch_mask = expired_codes) File "vector_quantize_pytorch/vector_quantize_pytorch.py", line 444, in replace self.embed.data[ind][mask] = sampled RuntimeError: shape mismatch: value tensor of shape [535, 256] cannot be broadcast to indexing result of shape [537, 256]

forwiat avatar Nov 06 '24 03:11 forwiat

@forwiat is this the latest version? thought i fixed this 🤔

try actually turning off code expiration, and just use rotation_trick = True. this new research finding may obsolete all these old hacks

lucidrains avatar Nov 06 '24 15:11 lucidrains

I try in many versions, such as 1.14.43, 1.15.x, 1.18.x ... thx for the solution! I will try it again!

forwiat avatar Nov 07 '24 06:11 forwiat