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 and Spaced Matrix Product Operator.
It supports different embedding functions, initialization techniques, and optimization strategies.
First create a virtualenv using pyenv
or conda
. Then install the package and its dependencies.
With pip
(tag v1.0.2):
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 local version of the package and install.
git clone https://github.com/bsc-quantic/tn4ml.git
pip install -e tn4ml/
Visit tn4ml.readthedocs.io
There are working examples of supervised learning (classification), and unsupervised learning (anomaly detection), both on MNIST images.
TN for Classification
TN for Anomaly Detection
TN for Anomaly Detection with DMRG-like method
MIT license - check it out here