{"id":13628704,"url":"https://github.com/tensorly/tensorly","last_synced_at":"2025-05-13T16:10:55.883Z","repository":{"id":37271280,"uuid":"71603727","full_name":"tensorly/tensorly","owner":"tensorly","description":"TensorLy: Tensor Learning in Python.","archived":false,"fork":false,"pushed_at":"2025-04-22T18:09:56.000Z","size":16783,"stargazers_count":1609,"open_issues_count":65,"forks_count":294,"subscribers_count":43,"default_branch":"main","last_synced_at":"2025-04-23T23:00:05.481Z","etag":null,"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"],"latest_commit_sha":null,"homepage":"http://tensorly.org","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tensorly.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.rst","funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS.rst","dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2016-10-21T23:14:52.000Z","updated_at":"2025-04-23T18:54:26.000Z","dependencies_parsed_at":"2023-12-25T17:49:41.552Z","dependency_job_id":"c268c19c-129a-461a-ba0b-f4749dc01925","html_url":"https://github.com/tensorly/tensorly","commit_stats":{"total_commits":1546,"total_committers":73,"mean_commits":21.17808219178082,"dds":0.6209573091849936,"last_synced_commit":"1fe1fc7ef575fc43abd0deab1366529470f5c0a6"},"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tensorly%2Ftensorly","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tensorly%2Ftensorly/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tensorly%2Ftensorly/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tensorly%2Ftensorly/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tensorly","download_url":"https://codeload.github.com/tensorly/tensorly/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250528731,"owners_count":21445516,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"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"],"created_at":"2024-08-01T22:00:56.175Z","updated_at":"2025-04-23T23:00:18.603Z","avatar_url":"https://github.com/tensorly.png","language":"Python","readme":".. image:: https://badge.fury.io/py/tensorly.svg\n    :target: https://badge.fury.io/py/tensorly\n\n.. image:: https://anaconda.org/tensorly/tensorly/badges/version.svg   \n    :target: https://anaconda.org/tensorly/tensorly\n\n.. image:: https://github.com/tensorly/tensorly/actions/workflows/test.yml/badge.svg?branch=main\n    :target: https://github.com/tensorly/tensorly/actions/workflows/test.yml\n\n.. image:: https://codecov.io/gh/tensorly/tensorly/branch/master/graph/badge.svg?token=mnZ234sGSA\n    :target: https://codecov.io/gh/tensorly/tensorly\n\n.. image:: https://img.shields.io/badge/Slack-join-brightgreen\n    :target: https://join.slack.com/t/tensorly/shared_invite/zt-wqnts2sk-wbiRX6ml~Xt6~GDYWRPFfg\n\n\n========\nTensorLy\n========\n   \n\nTensorLy 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.\n\n- **Website:** https://tensorly.org\n- **Source-code:**  https://github.com/tensorly/tensorly\n- **Jupyter Notebooks:** https://github.com/JeanKossaifi/tensorly-notebooks\n\n----------------------------\n\nInstalling TensorLy\n===================\n\nThe only pre-requisite is to have **Python 3** installed. The easiest way is via the `Anaconda distribution \u003chttps://www.anaconda.com/download/\u003e`_.\n\n+-------------------------------------------+---------------------------------------------------+\n|      **With pip** (recommended)           |         **With conda**                            |\n+-------------------------------------------+---------------------------------------------------+\n|                                           |                                                   |\n| .. code::                                 | .. code::                                         |\n|                                           |                                                   |\n|   pip install -U tensorly                 |   conda install -c tensorly tensorly              |\n|                                           |                                                   |\n|                                           |                                                   |\n+-------------------------------------------+---------------------------------------------------+\n|                               **Development (from git)**                                      |\n+-------------------------------------------+---------------------------------------------------+\n|                                                                                               |\n|          .. code::                                                                            |\n|                                                                                               |\n|             # clone the repository                                                            |\n|             git clone https://github.com/tensorly/tensorly                                    |\n|             cd tensorly                                                                       |\n|             # Install in editable mode with `-e` or, equivalently, `--editable`               |\n|             pip install -e .                                                                  |\n|                                                                                               |\n+-----------------------------------------------------------------------------------------------+  \n \n**Note:** TensorLy depends on NumPy by default. If you want to use other backends, you will need to install these packages separately.\n\nFor detailed instruction, please see the `documentation \u003chttp://tensorly.org/dev/installation.html\u003e`_.\n\n------------------\n\nQuickstart\n==========\n\nCreating tensors\n----------------\n\nCreate a small third order tensor of size 3 x 4 x 2, from a NumPy array and perform simple operations on it:\n\n.. code:: python\n\n   import tensorly as tl\n   import numpy as np\n\n\n   tensor = tl.tensor(np.arange(24).reshape((3, 4, 2)), dtype=tl.float64)\n   unfolded = tl.unfold(tensor, mode=0)\n   tl.fold(unfolded, mode=0, shape=tensor.shape)\n\n\nYou can also create random tensors:\n\n.. code:: python\n\n   from tensorly import random\n   \n   # A random tensor\n   tensor = random.random_tensor((3, 4, 2))\n   # A random CP tensor in factorized form\n   cp_tensor = random.random_tensor(shape=(3, 4, 2), rank='same')\n\nYou can also create tensors in TT-format, Tucker, etc, see `random tensors \u003chttp://tensorly.org/stable/modules/api.html#module-tensorly.random\u003e`_.\n\nSetting the backend\n-------------------\n\nYou 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:\n\n.. code:: python\n\n   tl.set_backend('pytorch') # Or 'numpy', 'tensorflow', 'cupy' or 'jax'\n   tensor = tl.tensor(np.arange(24).reshape((3, 4, 2)), device='cuda:0')\n   type(tensor) # torch.Tensor\n   \n\nTensor decomposition\n--------------------\n\nApplying tensor decomposition is easy:\n\n.. code:: python\n\n   from tensorly.decomposition import tucker\n   # Apply Tucker decomposition \n   tucker_tensor = tucker(tensor, rank=[2, 2, 2])\n   # Reconstruct the full tensor from the decomposed form\n   tl.tucker_to_tensor(tucker_tensor)\n   \nWe have `many more decompositions \u003chttp://tensorly.org/stable/modules/api.html#module-tensorly.decomposition\u003e`_ available, be sure to check them out!\n\nNext steps\n----------\nThis is just a very quick introduction to some of the basic features of TensorLy. \nFor more information on getting started, checkout the `user-guide \u003chttp://tensorly.org/dev/user_guide/index.html\u003e`_  and for a detailed reference of the functions and their documentation, refer to\nthe `API \u003chttp://tensorly.org/dev/modules/api.html\u003e`_   \n\nIf you see a bug, open an `issue \u003chttps://github.com/tensorly/tensorly/issues\u003e`_, or better yet, a `pull-request \u003chttps://github.com/tensorly/tensorly/pulls\u003e`_!\n  \n--------------------------\n\nContributing code\n=================\n\nAll 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 \u003chttps://github.com/tensorly/tensorly/\u003e`_.\n\nBefore you submit your changes, you should make sure your code adheres to our style-guide. The easiest way to do this is with `black`:  \n\n.. code:: bash\n\n   pip install black\n   black .\n\n\nRunning the tests\n=================\n\nTesting and documentation are an essential part of this package and all functions come with uni-tests and documentation.\n\nThe tests are ran using the `pytest` package. \nFirst install `pytest`::\n\n    pip install pytest\n    \nThen to run the test, simply run, in the terminal:\n\n.. code::\n\n   pytest -v tensorly\n   \nAlternatively, you can specify for which backend you wish to run the tests:\n\n.. code::\n   \n   TENSORLY_BACKEND='numpy' pytest -v tensorly\n \n\n------------------\n\nCiting\n======\n\nIf you use TensorLy in an academic paper, please cite [1]_::\n\n    @article{tensorly,\n      author  = {Jean Kossaifi and Yannis Panagakis and Anima Anandkumar and Maja Pantic},\n      title   = {TensorLy: Tensor Learning in Python},\n      journal = {Journal of Machine Learning Research},\n      year    = {2019},\n      volume  = {20},\n      number  = {26},\n      pages   = {1-6},\n      url     = {http://jmlr.org/papers/v20/18-277.html}\n    }\n    \n    \n.. [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.\n","funding_links":[],"categories":["\u003ca name=\"Tools\"\u003e\u003c/a\u003e13. Tools","Python","Linear Algebra / Statistics Toolkit","其他_机器学习与深度学习","Libraries","ریاضی","Deep Learning Tools"],"sub_categories":["13.7 Deployment","General Purpose Tensor Library","کار با زمان و تقویم"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftensorly%2Ftensorly","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftensorly%2Ftensorly","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftensorly%2Ftensorly/lists"}