Hyperdimensional computing / one-shot learning

Teach it a symbol

Invent a symbol, draw it three times, and a Sparsr device running in this browser tab will hold a class for it. Teach it a second one and it will tell them apart.

Sparsr VM starting a software model of the processor, running in this tab

This is a software model. The same kernels run unchanged through the Sparsr SDK on your own machine.

What is different about this one

The other demos here run a kernel over data somebody else prepared. This page starts with an empty device, and the classes in it are ones you invent while the page is open.

That is the property worth showing. A neural network learns a new class from many examples and a training run. Hyperdimensional computing learns one from a handful, in one pass, with nothing to retrain afterwards. It matters wherever a model has to be fitted to one person or one instrument rather than delivered finished.

Six instructions to teach, one per class to recognise

Your drawing becomes one hypervector, 4,096 bits wide. Every pixel position has its own fixed random vector, and an image is the vectors of its lit pixels combined. Two drawings of the same symbol light similar pixels, so they land close together.

Teaching a class is six instructions. Five of them vote: a bit of the class prototype is set where at least two of your three drawings set it. Over three vectors that majority is (a AND b) OR (a AND c) OR (b AND c), which the wide ALU computes exactly, with no counters and nothing coming back to the host. The sixth instruction stores the prototype in the device's memory, where it stays.

Three drawings rather than two or four is not a round number. A majority needs an odd number of voters, and three is the smallest that has one.

Recognising is one instruction per class. The device counts how many of the 4,096 bits differ between your drawing and each stored prototype, and the smallest count wins. On an ordinary 32-bit processor each of those comparisons is 128 separate operations.

Reading the numbers

Instruction counts, and nothing about speed. The device here is a software model running in your browser, so its wall-clock time is a property of your laptop rather than of Sparsr. The instruction counts are exact. Timing is left out on purpose, because a number that looked like a measurement would not be one.

It can be confused, and it will say so. If two classes end up with nearly the same prototype, the page tells you which pair and why, instead of picking one with false confidence. That usually means the three drawings of one symbol were not much alike. Draw each one the same way and it separates them easily.

The host prepares the drawing and encodes it. The device does the two things this page is about: building each prototype, and scoring your drawing against every class. No distance is computed outside the device.