A PyTorch implementation of Product Key Memory (PKM), an external memory module for neural networks with fast nearest-neighbor lookup via product quantization. Current version 0.3.0, requires Python >=3.6. Active development by lucidrains.
pip install product-key-memoryNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Creates a PKM module, applies it to random input, returns output and auxiliary loss.
Update code to expect only two return values. If you used aux_loss, it is now included in loss.
Ensure input is 3D: unsqueeze if necessary.
Use heads=1 or remove argument; check documentation.
Upgrade to latest: pip install --upgrade product-key-memory
Ensure both are on same device: model = model.to('cuda'); x = x.to('cuda')Remove return_loss; loss is now always computed and returned as second element.