tensorly

TensorLy: Tensor Learning in Python.

https://github.com/tensorly/tensorly

Science Score: 54.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
    10 of 72 committers (13.9%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (10.0%) to scientific vocabulary

Keywords

cupy decomposition jax machine-learning mxnet numpy python pytorch regression tensor tensor-algebra tensor-decomposition tensor-factorization tensor-learning tensor-methods tensor-regression tensorflow tensorly

Keywords from Contributors

tensors gtk qt tk wx keras embedded
Last synced: 6 months ago · JSON representation ·

Repository

TensorLy: Tensor Learning in Python.

Basic Info
  • Host: GitHub
  • Owner: tensorly
  • License: other
  • Language: Python
  • Default Branch: main
  • Homepage: http://tensorly.org
  • Size: 16.1 MB
Statistics
  • Stars: 1,609
  • Watchers: 43
  • Forks: 292
  • Open Issues: 64
  • Releases: 6
Topics
cupy decomposition jax machine-learning mxnet numpy python pytorch regression tensor tensor-algebra tensor-decomposition tensor-factorization tensor-learning tensor-methods tensor-regression tensorflow tensorly
Created over 9 years ago · Last pushed 10 months ago
Metadata Files
Readme Changelog Contributing License Citation Authors

README.rst

.. 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/actions/workflows/test.yml/badge.svg?branch=main
    :target: https://github.com/tensorly/tensorly/actions/workflows/test.yml

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

.. image:: https://img.shields.io/badge/Slack-join-brightgreen
    :target: https://join.slack.com/t/tensorly/shared_invite/zt-wqnts2sk-wbiRX6ml~Xt6~GDYWRPFfg


========
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, TensorFlow, CuPy or Paddle, and run methods at scale on CPU or GPU.

- **Website:** https://tensorly.org
- **Source-code:**  https://github.com/tensorly/tensorly
- **Jupyter Notebooks:** https://github.com/JeanKossaifi/tensorly-notebooks

----------------------------

Installing TensorLy
===================

The only pre-requisite is to have **Python 3** installed. The easiest way is via the `Anaconda distribution `_.

+-------------------------------------------+---------------------------------------------------+
|      **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 other backends, you will need to install these packages separately.

For detailed instruction, please see the `documentation `_.

------------------

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 `_.

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, JAX, CuPy or Paddle (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 '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 `_ 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 `_  and for a detailed reference of the functions and their documentation, refer to
the `API `_   

If you see a bug, open an `issue `_, or better yet, a `pull-request `_!
  
--------------------------

Contributing code
=================

All contributions are welcome! So if you have a cool tensor method you want to add, if you spot a bug or even a typo or mistake in the documentation, please report it, and even better, open a Pull-Request on `GitHub `_.

Before you submit your changes, you should make sure your code adheres to our style-guide. The easiest way to do this is with `black`:  

.. code:: bash

   pip install black
   black .


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. 
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.

Owner

  • Name: TensorLy
  • Login: tensorly
  • Kind: organization

Tensor Learning in Python.

Citation (CITATION.cff)

cff-version: 1.2.0
message: "If you use this software, please cite it as below."
authors:
- family-names: "TensorLy Team"
title: "TensorLy"
url: "https://github.com/github/tensorly"
preferred-citation:
  type: article
  authors:
    - family-names: "Kossaifi"
      given-names: "Jean"
    - family-names: "Panagakis"
      given-names: "Yannis"
    - family-names: "Anandkumark"
      given-names: "Anima"
    - family-names: "Pantic"
      given-names: "Maja"
  doi: "10.5555/3322706.3322732"
  journal: "Journal of Machine Learning Research"
  month: 1
  start: 1 # First page number
  end: 6 # Last page number
  title: "TensorLy: Tensor Learning in Python"
  issue: 26
  volume: 20
  year: 2019

GitHub Events

Total
  • Create event: 4
  • Release event: 2
  • Issues event: 17
  • Watch event: 85
  • Delete event: 4
  • Issue comment event: 48
  • Push event: 17
  • Pull request review event: 15
  • Pull request review comment event: 31
  • Pull request event: 23
  • Fork event: 14
Last Year
  • Create event: 4
  • Release event: 2
  • Issues event: 17
  • Watch event: 85
  • Delete event: 4
  • Issue comment event: 48
  • Push event: 17
  • Pull request review event: 15
  • Pull request review comment event: 31
  • Pull request event: 23
  • Fork event: 14

Committers

Last synced: 9 months ago

All Time
  • Total Commits: 1,715
  • Total Committers: 72
  • Avg Commits per committer: 23.819
  • Development Distribution Score (DDS): 0.654
Past Year
  • Commits: 118
  • Committers: 10
  • Avg Commits per committer: 11.8
  • Development Distribution Score (DDS): 0.686
Top Committers
Name Email Commits
Jean Kossaifi j****i@g****m 594
Aaron Meyer a****r@u****u 209
TUNA Caglayan c****a@i****r 134
Marie Roald r****e@g****m 105
Aaron Meurer a****r@g****m 68
COHEN Jeremy j****n@c****r 53
Aaron Meyer g****t@a****e 42
Meraj m****i@y****k 41
Christos Chatzis c****s@o****m 37
Yngve Mardal Moe y****e@g****m 34
taylorpatti t****i@g****u 25
Aaron Meyer g****b@a****g 25
Cyrillus c****n@g****m 24
Aaron Meyer g****t@a****g 21
Anthony Scopatz s****z@g****m 20
HydrogenSulfate 4****1@q****m 19
Jordan Matelsky j****8@g****m 18
Chris Swierczewski c****w@a****m 17
juliagusak j****k@g****m 16
Zongyi Li z****i@w****u 16
wumming j****d@g****m 15
Steven Braun s****z@g****m 14
Jim Crist j****t@g****m 14
Brian Orcutt-Jahns o****n@g****m 14
Lili l****g@s****u 13
SamJohannes s****r@l****k 11
Osman Asif Malik o****7@g****m 10
Yngve Moe y****e@N****O 9
COHEN Jeremy j****n@i****r 7
Christopher Yeh c****6 6
and 42 more...

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 106
  • Total pull requests: 120
  • Average time to close issues: 9 months
  • Average time to close pull requests: 2 months
  • Total issue authors: 67
  • Total pull request authors: 30
  • Average comments per issue: 2.81
  • Average comments per pull request: 3.74
  • Merged pull requests: 95
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 16
  • Pull requests: 27
  • Average time to close issues: 2 days
  • Average time to close pull requests: 15 days
  • Issue authors: 14
  • Pull request authors: 10
  • Average comments per issue: 0.31
  • Average comments per pull request: 1.37
  • Merged pull requests: 16
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • JeanKossaifi (13)
  • aarmey (8)
  • cohenjer (4)
  • hello-fri-end (4)
  • SCIKings (4)
  • MarieRoald (4)
  • wanglu2014 (3)
  • earmingol (3)
  • yngvem (3)
  • bakhtos (2)
  • cchatzis (2)
  • hameerabbasi (1)
  • maxscheurer (1)
  • braun-steven (1)
  • dohyun-kim92 (1)
Pull Request Authors
  • aarmey (47)
  • cohenjer (13)
  • JeanKossaifi (13)
  • HydrogenSulfate (5)
  • ax-le (4)
  • characat0 (4)
  • OsmanMalik (3)
  • dontempty (2)
  • cchatzis (2)
  • sebulo (2)
  • Mithrillion (2)
  • FBen3 (2)
  • braun-steven (2)
  • MarieRoald (2)
  • acotino-ignitioncomputing (2)
Top Labels
Issue Labels
enhancement (10) bug (8) API design (7) new feature (6) documentation (4) easy issue (3) performance/speed :fire: (1) In progress (1)
Pull Request Labels
bug (7) enhancement (5) performance/speed :fire: (3) API design (2) new feature (1) In progress (1)

Packages

  • Total packages: 3
  • Total downloads:
    • pypi 121,808 last-month
  • Total docker downloads: 235
  • Total dependent packages: 34
    (may contain duplicates)
  • Total dependent repositories: 216
    (may contain duplicates)
  • Total versions: 26
  • Total maintainers: 2
pypi.org: tensorly

Tensor learning in Python.

  • Versions: 19
  • Dependent Packages: 31
  • Dependent Repositories: 212
  • Downloads: 121,808 Last month
  • Docker Downloads: 235
Rankings
Dependent packages count: 0.5%
Dependent repos count: 1.0%
Average: 1.7%
Stargazers count: 1.8%
Docker downloads count: 2.1%
Downloads: 2.1%
Forks count: 3.0%
Maintainers (1)
Last synced: 6 months ago
conda-forge.org: 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, MXNet, PyTorch, TensorFlow or CuPy, and run methods at scale on CPU or GPU.

  • Versions: 6
  • Dependent Packages: 3
  • Dependent Repositories: 4
Rankings
Forks count: 10.7%
Stargazers count: 10.8%
Average: 13.3%
Dependent packages count: 15.6%
Dependent repos count: 16.2%
Last synced: 6 months ago
spack.io: py-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.

  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent repos count: 0.0%
Forks count: 5.6%
Stargazers count: 6.5%
Average: 17.5%
Dependent packages count: 57.9%
Maintainers (1)
Last synced: 6 months ago

Dependencies

.github/workflows/build_doc.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
.github/workflows/deploy_pypi.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
  • pypa/gh-action-pypi-publish master composite
.github/workflows/lint.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
.github/workflows/test.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
  • codecov/codecov-action v3 composite
doc/requirements_doc.txt pypi
  • jsmin *
  • matplotlib ==3.5.2
  • numpydoc *
  • rcssmin *
  • sphinx *
  • sphinx-gallery *
  • tensorly_sphinx_theme *
requirements.txt pypi
  • numpy *
  • pytest *
  • pytest-cov *
  • python_version >=
  • scipy *
setup.py pypi