Skip to main content

Tensor Networks for Machine Learning

Project description

logo

Tensor Networks for Machine Learning

Static Badge Static Badge
tn4ml is a Python library that handles tensor networks for machine learning applications.
It is built on top of Quimb, for Tensor Network objects, and JAX, for optimization pipeline.
For now, the library supports 1D Tensor Network structures:

  • Matrix Product State
  • Matrix Product Operator
  • Spaced Matrix Product Operator

It supports different embedding functions, initialization techniques, objective functions and optimization strategies.

Installation

First create a virtualenv using pyenv or conda. Then install the package and its dependencies.

With pip (tag v1.0.4):

pip install tn4ml

or directly from github:

pip install -U git+https://github.com/bsc-quantic/tn4ml.git

If you want to test and edit the code, you can clone the local version of the package and install it.

git clone https://github.com/bsc-quantic/tn4ml.git
pip install -e tn4ml/

Accelerated runtime

(Optional) To improve runtime precision set these flags:

jax.config.update("jax_enable_x64", True)
jax.config.update('jax_default_matmul_precision', 'highest')

Running on GPU
Before everything install JAX version that supports CUDA and its suitable for runs on GPU.
Checkout how to install here: jax[cuda]

Next, at the beginning of your script set:

import os
os.environ["CUDA_VISIBLE_DEVICES"] = "0"  # Use GPU 0 - or set any GPU ID
import jax
jax.config.update("jax_platform_name", 'gpu')

Then when training Model set:

device = 'gpu'
model.configure(device=device)

Documentation

Visit tn4ml.readthedocs.io

Example notebooks

TN for Classification
TN for Anomaly Detection
TN for Anomaly Detection with DMRG-like method

License

MIT license - check it out here

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

tn4ml-1.0.4.tar.gz (47.4 kB view details)

Uploaded Source

Built Distribution

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

tn4ml-1.0.4-py3-none-any.whl (54.7 kB view details)

Uploaded Python 3

File details

Details for the file tn4ml-1.0.4.tar.gz.

File metadata

  • Download URL: tn4ml-1.0.4.tar.gz
  • Upload date:
  • Size: 47.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.21

File hashes

Hashes for tn4ml-1.0.4.tar.gz
Algorithm Hash digest
SHA256 f1594740d33367146eb37e623f80294cee59b83ab549d00031a87b9163ac32ef
MD5 e1a9c1c28586c49fb186bf0dda1690d0
BLAKE2b-256 f3ec898e3b68a82b893e3c22be4c9c3ec52b8eda0a8e7fb59233f5790b0f0c3f

See more details on using hashes here.

File details

Details for the file tn4ml-1.0.4-py3-none-any.whl.

File metadata

  • Download URL: tn4ml-1.0.4-py3-none-any.whl
  • Upload date:
  • Size: 54.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.21

File hashes

Hashes for tn4ml-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 dde0df22f6c5b150e28eee1e40878ba05b10d8c269cabf59ad45f6ea14f91067
MD5 1d501072b96342de1406e537e86060c1
BLAKE2b-256 98b743128d6c73bbaeb8a75c35c233a7a0669663f91e8b04f1f3f1abf1ca787b

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