Note
Go to the end to download the full example code.
HRR correlation vs convolution demoΒΆ
Shows how circular correlation approximates unbinding for HRR.
8 import numpy as np
9
10 from holovec.backends import get_backend
11 from holovec.models.hrr import HRRModel
12
13
14 def main():
15 be = get_backend('numpy')
16 model = HRRModel(dimension=512, backend=be, seed=0)
17 a = model.random(seed=1)
18 b = model.random(seed=2)
19 c = model.bind(a, b) # circular convolution
20
21 # Unbinding via circular correlation
22 b_hat = model.unbind(c, a)
23 sim = model.similarity(b, b_hat)
24 print(f"corr-unbind similarity: {sim:.3f}")
25
26
27 if __name__ == "__main__":
28 main()