DEV Community

Andrale
Andrale

Posted on

HDC model for dummies (18+)

So well come to my guide for HDC(hyperdimension computing)for beginners and dummies, so ur here to learn HDC good, very maso, love it, 1.first u need python(1.0+)
2.next for libraries it's pytorch + torchdd or holo(If ur feeling extra kinky) which is a rust-python wrapper,

  1. AI example code import torch import torchhd

1. Set the dimensionality

d = 1000 # The "1000D" you mentioned

2. Create a random hypervector (your first "memory")

hv = torchhd.random(1, d) # A tensor with 1,000 random values
print(f"Hypervector shape: {hv.shape}")

3. The fundamental operations

hv2 = torchhd.random(1, d)

BUNDLE (superposition): Think of this as creating a "set" or a "noisy" memory

bundled_hv = torchhd.bundle(hv, hv2)

BIND (association): This creates a new hypervector that encodes a relationship

bound_hv = torchhd.bind(hv, hv2)

4. Similarity (the "search" and "recognition" function)

similarity = torchhd.cosine_similarity(hv, hv2)
print(f"Similarity between two random vectors: {similarity.item():.4f}")

You'll see a number close to 0, as random vectors are nearly orthogonal.

(I recommend claude for free and gemini pro if ur rich πŸ€‘to code for you if ur feeling extra romantic)

  1. I recommend starting at 1k D, cos it's easier to control and won't get you scratching ur head but itching for more
  2. I recommend thinking them of a sheet of graphene(2D) to help u visualise, if ur feeling smart try thinking them of diamond lattice(3D), if u feel even spicier image them as a universe with galaxies as moving nodes cos "distance" is now an abstract concept
  3. Stay hydrated
  4. Have fun 😊
  5. Ask questions, cos it's better if ur responsive and ready to learn -teehee ✨😘

Top comments (0)