Skip to main content

A PyTorch implementation of non-negative similarity matching

Project description

Non-negative similarity matching in PyTorch

PyPI Version Python 3.8+ License

This is an implementation of non-negative similarity matching (NSM) for PyTorch focusing on ease of use, extensibility, and speed.

Getting started

You can install the package from PyPI by using

pip install pynsm

User documentation

Find examples, how-to guides, tutorials, and full API reference information on Readthedocs, https://pynsm.readthedocs.io/.

Questions or issues?

Please contact us by opening an issue on GitHub.




Instructions for developers

Developer installation

It is strongly recommended to use a virtual environment when working with this code. The installation instructions below include the commands for creating the virtual environment, using either conda (recommended) or venv.

Developer install using conda

If you do not have conda installed, the easiest way to get started is with Miniconda. Follow the installation instructions for your system.

Next, create a new environment and install for CPU using

conda env create -f environment.yml

For using an NVIDIA GPU run

conda env create -f environment-cuda.yml

Note that most Macs do not have an NVIDIA GPU, so you should use the first invocation shown above. If your Mac uses the newer Apple chips, you may be able to use device=mps to get GPU acceleration (the installation procedure remains unchanged).

The commands above automatically perform an "editable" install—this means that changes made to the code will automatically take effect without having to reinstall the package.

Developer install using venv

Before creating a new virtual environment, it is best to ensure you're not using the system version of Python—this is often badly out of date. Some options for doing this are outlined in The Hitchhiker's Guide to Python, although many options exist. One advantage of using conda is that this is done for you.

Once you have a proper Python install, create a new virtual environment by running the following command in a terminal inside the main folder of the repository:

python -m venv env

This creates a subfolder called env containing the files for the virtual environment. Next we need to activate the environment and install the package with its pre-requisites:

source env/bin/activate
pip install -e ".[dev]"

The -e marks this as an "editable" install—this means that changes made to the code will automatically take effect without having to reinstall the package.

Example usage

See the notebooks in the examples folder to get started with the package. The information on readthedocs may also prove useful.

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

pynsm-1.0.1.tar.gz (3.9 MB view details)

Uploaded Source

Built Distribution

pynsm-1.0.1-py3-none-any.whl (12.7 kB view details)

Uploaded Python 3

File details

Details for the file pynsm-1.0.1.tar.gz.

File metadata

  • Download URL: pynsm-1.0.1.tar.gz
  • Upload date:
  • Size: 3.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for pynsm-1.0.1.tar.gz
Algorithm Hash digest
SHA256 394ef35ee9d828e792c7682bd9738763dc63d5c704d4f68c8804b29ee079004a
MD5 c3a512de135cd8005563eb715c0866db
BLAKE2b-256 8ae096f58658aac50f9607089ed75ae7cf7373b5d961aee739a0ec3168475d2f

See more details on using hashes here.

File details

Details for the file pynsm-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: pynsm-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 12.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for pynsm-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 29c74991acdcacd6d5245e234a6405c534e274e6ce1c11908800cc607177ee3d
MD5 68f9d97ae4e7295f285d186c2130fd5f
BLAKE2b-256 00c63234b3efb6ff2ca4e6a3137c4a7b87d5d80027d6835e46cae9425cbac64d

See more details on using hashes here.

Supported by

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