tensorly
Tensor learning in Python.
What it is and what it does
TensorLy is a Python library for tensor operations—decomposition, learning, and algebra—built on top of numpy and scipy. It abstracts away the computational backend so you can write tensor code once and run it on NumPy arrays, PyTorch tensors, JAX arrays, or other frameworks without rewriting. You define which backend to use, and all operations transparently use that framework's compute engine, including GPU acceleration when available.
The library covers standard tensor decompositions (Tucker, CP, TT-format and others), random tensor generation, unfolding/folding operations, and tensor reconstruction. It's designed for researchers and practitioners who need to prototype or deploy tensor methods across different computational backends without maintaining separate codebases for each one.
Use it for:
- Prototype tensor decomposition algorithms in NumPy, then run the same code on GPU via PyTorch or TensorFlow for production.
- Perform Tucker or CP decomposition on large multidimensional datasets for dimensionality reduction or feature extraction.
- Build machine learning pipelines that work with both CPU and GPU backends by switching a single configuration parameter.
- Unfold and manipulate high-order tensors for signal processing, chemometrics, or scientific computing workflows.
- Experiment with different tensor factorization methods on the same data without rewriting tensor algebra code.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
TensorLy performs tensor decomposition, tensor learning, and tensor algebra operations with a pluggable backend system that lets you compute using NumPy, PyTorch, JAX, TensorFlow, CuPy, or Paddle.
Yes, if you need tensor decomposition and can accept a slower release cycle. The library has low install friction, permissive licensing, no known vulnerabilities, and a multi-backend design that justifies the abstraction overhead. The aging maintenance status is a minor concern but not a blocker—the repository is not archived and recent commits exist. Install it for prototyping or production use of tensor methods across NumPy, PyTorch, or other backends.
Install
tensorly on PyPI
pip
pip install tensorlyuv
uv add tensorlypoetry
poetry add tensorlyInstalling tensorly
Before you install
Low install friction with only numpy and scipy as runtime dependencies. The package is aging (640 days since last release) but the repository remains active with recent commits and no archived status, suggesting ongoing maintenance despite the slower release cadence.
License in practice
Licensed under Modified BSD (permissive), which allows commercial and private use with minimal restrictions—suitable for most projects that can include the license text.
Quickstart
pip install tensorly
import tensorly as tl
import numpy as np
tensor = tl.tensor(np.arange(24).reshape((3, 4, 2)))
unfolded = tl.unfold(tensor, mode=0)
reconstructed = tl.fold(unfolded, mode=0, shape=tensor.shape)
Requires Python 3; optional backends (PyTorch, TensorFlow, JAX, CuPy, Paddle) must be installed separately if you want to use them instead of NumPy.
Verify before relying
- Whether the aging status (640 days since release) reflects planned maintenance cycles or slowing development momentum.
- Performance characteristics and scalability limits for large-scale tensor operations on GPU.
- Completeness and currency of documentation relative to the latest decomposition methods in the field.
Package facts
| License | Modified BSD (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — numpy, scipy |
| Maintenance | aging — 640 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 109,991/month — #12,489 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: tensorly-0.9.0-py3-none-any.whl
Tags
More Scientific/Engineering packages
NumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
pandaspandas provides fast, flexible data structures…
permissive · top 100 on PyPI
scipyscipy provides numerical algorithms for…
permissive · top 100 on PyPI
scikit-learnscikit-learn provides a comprehensive Python…
permissive · top 1,000 on PyPI
dilldill extends Python's pickle module to…
permissive · top 1,000 on PyPI
multiprocessMultiprocess is an enhanced fork of Python's…
permissive · top 1,000 on PyPI
autorayAutoray provides automatic dispatch of array…
permissive · top 15,000 on PyPI
eigenpyEigenPy provides Python bindings between NumPy…
permissive · top 5,000 on PyPI
torchPyTorch provides GPU-accelerated tensor…
permissive · top 1,000 on PyPI
tensorflow-cpuTensorFlow CPU provides a machine learning and…
permissive · top 5,000 on PyPI
keras-nightlyA multi-backend deep learning framework that…
permissive · top 15,000 on PyPI
einopsEinops provides readable tensor operations…
permissive · top 1,000 on PyPI
tensordictTensorDict is a batched, nested dictionary…
permissive · top 5,000 on PyPI
docarrayDocArray provides a Python data structure for…
permissive · top 15,000 on PyPI
torch-complexProvides a Python class wrapping real and…
permissive · top 15,000 on PyPI
tensordict-nightlyTensorDict is a batched, nested dictionary…
permissive · top 15,000 on PyPI