All Projects → tensorly → Tensorly

tensorly / Tensorly

Licence: other
TensorLy: Tensor Learning in Python.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Tensorly

Mobulaop
A Simple & Flexible Cross Framework Operators Toolkit
Stars: ✭ 161 (-83.52%)
Mutual labels:  mxnet, cupy, numpy
Cupy
NumPy & SciPy for GPU
Stars: ✭ 5,625 (+475.74%)
Mutual labels:  tensor, cupy, numpy
Einops
Deep learning operations reinvented (for pytorch, tensorflow, jax and others)
Stars: ✭ 4,022 (+311.67%)
Mutual labels:  tensor, cupy, numpy
Ivy
The templated deep learning framework, enabling framework-agnostic functions, layers and libraries.
Stars: ✭ 118 (-87.92%)
Mutual labels:  mxnet, numpy
Mtensor
A C++ Cuda Tensor Lazy Computing Library
Stars: ✭ 115 (-88.23%)
Mutual labels:  tensor, numpy
Mars
Mars is a tensor-based unified framework for large-scale data computation which scales numpy, pandas, scikit-learn and Python functions.
Stars: ✭ 2,308 (+136.23%)
Mutual labels:  tensor, numpy
Gluon Nlp
NLP made easy
Stars: ✭ 2,344 (+139.92%)
Mutual labels:  mxnet, numpy
python cv AI ML
用python做计算机视觉,人工智能,机器学习,深度学习等
Stars: ✭ 73 (-92.53%)
Mutual labels:  mxnet, numpy
NDScala
N-dimensional arrays in Scala 3. Think NumPy ndarray, but type-safe over shapes, array/axis labels & numeric data types
Stars: ✭ 37 (-96.21%)
Mutual labels:  numpy, tensor
Xshinnosuke
Deep learning framework realized by Numpy purely, supports for both Dynamic Graph and Static Graph with GPU acceleration
Stars: ✭ 291 (-70.21%)
Mutual labels:  cupy, numpy
robot
Functions and classes for gradient-based robot motion planning, written in Ivy.
Stars: ✭ 29 (-97.03%)
Mutual labels:  mxnet, numpy
Megengine
MegEngine 是一个快速、可拓展、易于使用且支持自动求导的深度学习框架
Stars: ✭ 4,081 (+317.71%)
Mutual labels:  numpy, tensor
Pytorch
Tensors and Dynamic neural networks in Python with strong GPU acceleration
Stars: ✭ 52,811 (+5305.42%)
Mutual labels:  tensor, numpy
Cloud Volume
Read and write Neuroglancer datasets programmatically.
Stars: ✭ 63 (-93.55%)
Mutual labels:  tensor, numpy
Pynvvl
A Python wrapper of NVIDIA Video Loader (NVVL) with CuPy for fast video loading with Python
Stars: ✭ 95 (-90.28%)
Mutual labels:  cupy, numpy
PuzzleLib
Deep Learning framework with NVIDIA & AMD support
Stars: ✭ 52 (-94.68%)
Mutual labels:  numpy, tensor
Chainer
A flexible framework of neural networks for deep learning
Stars: ✭ 5,656 (+478.92%)
Mutual labels:  cupy, numpy
Drlkit
A High Level Python Deep Reinforcement Learning library. Great for beginners, prototyping and quickly comparing algorithms
Stars: ✭ 29 (-97.03%)
Mutual labels:  tensor, numpy
Numsharp
High Performance Computation for N-D Tensors in .NET, similar API to NumPy.
Stars: ✭ 882 (-9.72%)
Mutual labels:  numpy
Efficientnet
Gluon implementation of EfficientNet and EfficientNet-lite
Stars: ✭ 30 (-96.93%)
Mutual labels:  mxnet

.. image:: https://badge.fury.io/py/tensorly.svg :target: https://badge.fury.io/py/tensorly

.. image:: https://anaconda.org/tensorly/tensorly/badges/version.svg
:target: https://anaconda.org/tensorly/tensorly

.. image:: https://github.com/tensorly/tensorly/workflows/Test%20TensorLy/badge.svg :target: https://github.com/tensorly/tensorly/actions?query=workflow%3A%22Test+TensorLy%22

.. image:: https://codecov.io/gh/tensorly/tensorly/branch/master/graph/badge.svg?token=mnZ234sGSA :target: https://codecov.io/gh/tensorly/tensorly

.. image:: https://badges.gitter.im/tensorly/tensorly.svg :target: https://gitter.im/tensorly/tensorly?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge

======== TensorLy

TensorLy is a Python library that aims at making tensor learning simple and accessible. It allows to easily perform tensor decomposition, tensor learning and tensor algebra. Its backend system allows to seamlessly perform computation with NumPy, PyTorch, JAX, MXNet, TensorFlow or CuPy, and run methods at scale on CPU or GPU.


Installing TensorLy

The only pre-requisite is to have Python 3 installed. The easiest way is via the Anaconda distribution <https://www.anaconda.com/download/>_.

+-------------------------------------------+---------------------------------------------------+ |     With pip (recommended) |         With conda | +-------------------------------------------+---------------------------------------------------+ | | | | .. code:: | .. code:: | | | | | pip install -U tensorly | conda install -c tensorly tensorly | | | | | | | +-------------------------------------------+---------------------------------------------------+ | Development (from git) | +-------------------------------------------+---------------------------------------------------+ | | | .. code:: | | | | # clone the repository | | git clone https://github.com/tensorly/tensorly | | cd tensorly | | # Install in editable mode with -e or, equivalently, --editable | | pip install -e . | | | +-----------------------------------------------------------------------------------------------+

Note: TensorLy depends on NumPy by default. If you want to use the MXNet or PyTorch backends, you will need to install these packages separately.

For detailed instruction, please see the documentation <http://tensorly.org/dev/installation.html>_.


Quickstart

Creating tensors

Create a small third order tensor of size 3 x 4 x 2, from a NumPy array and perform simple operations on it:

.. code:: python

import tensorly as tl import numpy as np

tensor = tl.tensor(np.arange(24).reshape((3, 4, 2)), dtype=tl.float64) unfolded = tl.unfold(tensor, mode=0) tl.fold(unfolded, mode=0, shape=tensor.shape)

You can also create random tensors:

.. code:: python

from tensorly import random

A random tensor

tensor = random.random_tensor((3, 4, 2))

A random CP tensor in factorized form

cp_tensor = random.random_tensor(shape=(3, 4, 2), rank='same')

You can also create tensors in TT-format, Tucker, etc, see random tensors <http://tensorly.org/stable/modules/api.html#module-tensorly.random>_.

Setting the backend

You can change the backend to perform computation with a different framework. By default, the backend is NumPy, but you can also perform the computation using PyTorch, TensorFlow, MXNet, JAX or CuPy (requires to have installed them first). For instance, after setting the backend to PyTorch, all the computation is done by PyTorch, and tensors can be created on GPU:

.. code:: python

tl.set_backend('pytorch') # Or 'mxnet', 'numpy', 'tensorflow', 'cupy' or 'jax' tensor = tl.tensor(np.arange(24).reshape((3, 4, 2)), device='cuda:0') type(tensor) # torch.Tensor

Tensor decomposition

Applying tensor decomposition is easy:

.. code:: python

from tensorly.decomposition import tucker

Apply Tucker decomposition

tucker_tensor = tucker(tensor, rank=[2, 2, 2])

Reconstruct the full tensor from the decomposed form

tl.tucker_to_tensor(tucker_tensor)

We have many more decompositions <http://tensorly.org/stable/modules/api.html#module-tensorly.decomposition>_ available, be sure to check them out!

Next steps

This is just a very quick introduction to some of the basic features of TensorLy. For more information on getting started, checkout the user-guide <http://tensorly.org/dev/user_guide/index.html>_ and for a detailed reference of the functions and their documentation, refer to the API <http://tensorly.org/dev/modules/api.html>_

If you see a bug, open an issue <https://github.com/tensorly/tensorly/issues>, or better yet, a pull-request <https://github.com/tensorly/tensorly/pulls>!


Running the tests

Testing and documentation are an essential part of this package and all functions come with uni-tests and documentation.

The tests are ran using the pytest package (though you can also use nose). First install pytest::

pip install pytest

Then to run the test, simply run, in the terminal:

.. code::

pytest -v tensorly

Alternatively, you can specify for which backend you wish to run the tests:

.. code::

TENSORLY_BACKEND='numpy' pytest -v tensorly


Citing

If you use TensorLy in an academic paper, please cite [1]_::

@article{tensorly,
  author  = {Jean Kossaifi and Yannis Panagakis and Anima Anandkumar and Maja Pantic},
  title   = {TensorLy: Tensor Learning in Python},
  journal = {Journal of Machine Learning Research},
  year    = {2019},
  volume  = {20},
  number  = {26},
  pages   = {1-6},
  url     = {http://jmlr.org/papers/v20/18-277.html}
}

.. [1] Jean Kossaifi, Yannis Panagakis, Anima Anandkumar and Maja Pantic, TensorLy: Tensor Learning in Python, Journal of Machine Learning Research (JMLR), 2019, volume 20, number 26.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].