Skip to main content

Python library for Hyperdimensional Computing

Project description

Hyperdimensional Computing Library

GitHub license pypi version tests status PRs Welcome

This is a Python library for Hyperdimensional Computing.

  • Easy-to-use: This library makes it painless to develop a wide range of Hyperdimensional Computing (HDC) applications and algorithms. For someone new to the field we provide Pythonic abstractions and examples to get you started fast. For the experienced researchers we made the library modular by design, giving you endless flexibility to prototype new ideas in no-time.
  • Performant: The library is build on top of the high-performance PyTorch library, giving you optimized tensor execution without the headaches. Moreover, PyTorch makes it effortless to accelerate your code on a GPU.

Installation

The library is hosted on PyPi and Conda, use one of the following commands to install:

pip install hdc
conda install -c conda-forge hdc

Documentation

You can find the library's documentation on the website.

Examples

We have several examples in the repository. Here is a simple one to get you started:

import hdc
import torch

d = 10000  # number of dimensions

### create a hypervector for each symbol
# keys for each field of the dictionary: fruit, weight, and season
keys = hdc.functional.random_hv(3, d)
# fruits are: apple, lemon, mango
fruits = hdc.functional.random_hv(3, d)
# there are 10 weight levels
weights = hdc.functional.level_hv(10, d)
# the for seasons: winter, spring, summer, fall
seasons = hdc.functional.circular_hv(4, d)

# map a float between min, max to an index of size 10
# we map the 10 weight levels between 0 to 200 grams
weight_index = hdc.functional.value_to_index(149.0, 0, 200, 10)

values = torch.stack([
    fruits[0],
    weights[weight_index],
    seasons[3],
])
# creates a dictionary: 
# record = key[0] * value[0] + key[1] * value[1] + key[2] * value[2]
record = hdc.functional.struct(keys, values)

#### Similar Python code
# 
# record = dict(
#     fruit="apple", 
#     weight=149.0,
#     season="fall"
# )
# 

This example creates a hypervector that represents the record of a fruit, storing its species, weight, and growing season as one hypervector. This is achieved by combining the atomic information units into a structure (similar to a Python dictionary).

You will notice that we first declare all the symbols which are used to represent information. Note the type of hypervector used for each type of information, the fruits and keys use random hypervectors as they represent unrelated information whereas the weights and seasons use level and circular-hypervectors because they have linear and circular-correlations, respectively.

Contributing

Creating a New Release

  • A GitHub release triggers a GitHub action that builds the library and publishes it to PyPi and Conda in addition to the documentation website.
  • Before creating a new GitHub release, increment the version number in setup.py using semantic versioning.
  • When creating a new GitHub release, set the tag to be "v{version number}", e.g., v1.5.2, and provide a clear description of the changes.

License

This library is MIT licensed.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hdc-0.5.5.tar.gz (9.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hdc-0.5.5-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file hdc-0.5.5.tar.gz.

File metadata

  • Download URL: hdc-0.5.5.tar.gz
  • Upload date:
  • Size: 9.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.12

File hashes

Hashes for hdc-0.5.5.tar.gz
Algorithm Hash digest
SHA256 4d928ea3753d8dd815cd5de6fc8064fbbe6f2ef7ffaa2ab1f79584618f263005
MD5 1d10df5411adfbf06b4e8ca1ee173f3b
BLAKE2b-256 d08573650cf2695deb22e99d9b1bf6fe647ded327e21c732d8d407d608f893b8

See more details on using hashes here.

File details

Details for the file hdc-0.5.5-py3-none-any.whl.

File metadata

  • Download URL: hdc-0.5.5-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.12

File hashes

Hashes for hdc-0.5.5-py3-none-any.whl
Algorithm Hash digest
SHA256 5d3e89c83d42feb5b4b75645ae17d2e947d3cba9de902654e65a3956713b7b33
MD5 4b531430bd13f9ce864005fd223fb97e
BLAKE2b-256 a0a25cae1cf49b00523f1063a3a5e3ccd68c6f1595c29ab494efda92ed05d71f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page