|
1 | | -# Hyperdimensional Computing Library |
| 1 | +<h1 align="center"> |
| 2 | + <a href="https://mikeheddes.github.io/hdc-lib">Hyperdimensional Computing Library</a><br/> |
2 | 3 |
|
3 | | -The `hdc` library is a comprehensive package for all hyperdimensional computing related tasks. |
| 4 | +</h1> |
| 5 | +<p align="center"> |
| 6 | + <a href="https://github.com/mikeheddes/hdc-lib/blob/main/LICENSE"> |
| 7 | + <img alt="GitHub license" src="https://img.shields.io/badge/license-MIT-orange.svg?style=flat" /></a> |
| 8 | + <a href="https://pypi.org/project/hdc/"><img alt="pypi version" src="https://img.shields.io/pypi/v/hdc.svg?style=flat&color=orange" /></a> |
| 9 | + <a href="https://github.com/mikeheddes/hdc-lib/actions/workflows/test.yml?query=branch%3Amain"><img alt="tests status" src="https://img.shields.io/github/workflow/status/mikeheddes/hdc-lib/Testing/main?label=tests&style=flat" /></a> |
| 10 | + <img alt="PRs Welcome" src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat" /> |
| 11 | +</p> |
| 12 | + |
| 13 | +This is a Python library for Hyperdimensional Computing. |
| 14 | + |
| 15 | +* **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. |
| 16 | +* **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. |
4 | 17 |
|
5 | 18 | ## Installation |
6 | 19 |
|
| 20 | +The library is hosted on PyPi and Conda, use one of the following commands to install: |
| 21 | + |
7 | 22 | ```bash |
8 | | -# Note: torch is a prerequisite of hdc, see: https://pytorch.org/get-started/locally/ for an installation guide. |
9 | 23 | pip install hdc |
10 | 24 | ``` |
11 | 25 |
|
12 | | -## Creating a new release |
| 26 | +```bash |
| 27 | +conda install -c conda-forge hdc |
| 28 | +``` |
| 29 | + |
| 30 | +## Documentation |
| 31 | + |
| 32 | +You can find the library's documentation [on the website](https://mikeheddes.github.io/hdc-lib). |
| 33 | + |
| 34 | +## Examples |
| 35 | + |
| 36 | +We have several examples [in the repository](/examples/). Here is a simple one to get you started: |
| 37 | + |
| 38 | +```python |
| 39 | +import hdc |
| 40 | +import torch |
| 41 | + |
| 42 | +d = 10000 # number of dimensions |
| 43 | + |
| 44 | +### create a hypervector for each symbol |
| 45 | +# keys for each field of the dictionary: fruit, weight, and season |
| 46 | +keys = hdc.functional.random_hv(3, d) |
| 47 | +# fruits are: apple, lemon, mango |
| 48 | +fruits = hdc.functional.random_hv(3, d) |
| 49 | +# there are 10 weight levels |
| 50 | +weights = hdc.functional.level_hv(10, d) |
| 51 | +# the for seasons: winter, spring, summer, fall |
| 52 | +seasons = hdc.functional.circular_hv(4, d) |
| 53 | + |
| 54 | +# map a float between min, max to an index of size 10 |
| 55 | +# we map the 10 weight levels between 0 to 200 grams |
| 56 | +weight_index = hdc.functional.value_to_index(149.0, 0, 200, 10) |
| 57 | + |
| 58 | +values = torch.stack([ |
| 59 | + fruits[0], |
| 60 | + weights[weight_index], |
| 61 | + seasons[3], |
| 62 | +]) |
| 63 | +# creates a dictionary: |
| 64 | +# record = key[0] * value[0] + key[1] * value[1] + key[2] * value[2] |
| 65 | +record = hdc.functional.struct(keys, values) |
| 66 | + |
| 67 | +#### Similar Python code |
| 68 | +# |
| 69 | +# record = dict( |
| 70 | +# fruit="apple", |
| 71 | +# weight=149.0, |
| 72 | +# season="fall" |
| 73 | +# ) |
| 74 | +# |
| 75 | +``` |
| 76 | + |
| 77 | +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). |
| 78 | + |
| 79 | +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. |
| 80 | + |
| 81 | +## Contributing |
| 82 | + |
| 83 | +### Creating a New Release |
| 84 | + |
| 85 | +- A GitHub release triggers a GitHub action that builds the library and publishes it to PyPi and Conda in addition to the documentation website. |
| 86 | +- Before creating a new GitHub release, increment the version number in [setup.py](/setup.py) using [semantic versioning](https://semver.org). |
| 87 | +- 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. |
13 | 88 |
|
14 | | -- Before creating a new release, increment the version number by 0.1 to have the workflow update the PyPi documentation. |
15 | | -- On creating a new release, set the tag to be "v{version number}". Example: v0.5 |
| 89 | +### License |
16 | 90 |
|
17 | | -New release should update both the PyPi library as well as documentation website. |
| 91 | +This library is [MIT licensed](./LICENSE). |
0 commit comments