hyperdimensional-computing / torchhd

Torchhd is a Python library for Hyperdimensional Computing and Vector Symbolic Architectures
https://torchhd.readthedocs.io
MIT License
229 stars 24 forks source link

Design to allow easy comparison of alternate versions of VSA primitives (and other functions) #74

Closed rgayler closed 1 year ago

rgayler commented 2 years ago

Given the existence of alternate versions of the primitive functions, e.g. binding by circular convolution or elementwise product, (see #73), people will want to compare them.

Ideally, a user would write something like: similarity(bundle(bind(A,B),C), X) and be able to execute it for different definitions of the functions without having to rewrite that code snippet.

The implementation might be as simple as something like similarity = similarity.cosine; bind = bind.convolution; bundle = bundle.add before executing the code snippet. (Sorry if that's not pythonic.)

At the moment {Torchhd} implements bind(), bundle(), etc. which sort of implies that the current definitions are the only definitions. I think the names bind, bundle, etc. should be reserved for the generic operators and the actual implementations should have more specific names like bind.convolution and bundle.add. Then the specific operators can be assigned to the generic names as needed (in a pythonic way).

I think this approach should be taken to all the functions that might be viewed generically: definitely VSA primitive operators and similarity; very probably the encodings and atomic vector generators; probably cleanup.

Maybe this is absolutely trivial in python and doesn't require any design as such. If that's the case, then the documentation should explicitly show how to compare alternate implementations in a pythonic way.