neuron-explorer
Qwen3.5‑4B 전용 조향형 뉴런 탐색기, 모든 MLP 뉴런을 밀어 결과를 보관·탐색
TensorLy, 파이썬에서 텐서 학습
TensorLy: Tensor Learning in Python.
개발 도구Python · ShellGitHub @tensorly직접 설치운영자 미확인
써 보셨어요? 한 번만 눌러 주세요. 로그인은 필요 없어요.
개인 계정의 공개 저장소 소유자는 GitHub로 로그인해 운영자를 확인하고 소개를 직접 관리할 수 있습니다. 관리자 승인은 필요하지 않습니다.
로그인한 뒤 확인 파일을 만들어 이 저장소의 기본 브랜치에 30분 안에 커밋해 주세요. 다른 브랜치나 포크의 파일은 인정하지 않습니다. 파일을 올린 뒤 아래에서 확인하면 관리자 승인 없이 관리할 수 있습니다. 자격을 유지하려면 파일을 남겨 두세요.
로그인이 필요하면 로그인 화면으로 이동합니다. 로그인 후 이곳으로 돌아와 원하는 확인 버튼을 다시 눌러 주세요.
설치형 프로젝트는 배포 도메인 없이도 확인할 수 있습니다. 개인 저장소는 GitHub 로그인으로, 조직 저장소는 위의 저장소 확인 파일로 직접 확인해 주세요.
메이커가 쓴 소개는 위의 한 줄이 전부입니다. 더 자세한 내용은 저장소 README에서 읽을 수 있습니다. 저장소 README ↗
README 전체를 불러오는 중입니다.
README 전문 보기 ↗.. 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 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.
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 other backends, you will need to install these packages separately.
For detailed instruction, please see the documentation <http://tensorly.org/dev/installation.html>_.
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
tensor = random.random_tensor((3, 4, 2))
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>_.
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
Applying tensor decomposition is easy:
.. code:: python
from tensorly.decomposition import tucker
tucker_tensor = tucker(tensor, rank=[2, 2, 2])
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!
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>!
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 <https://github.com/tensorly/tensorly/>_.
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 .
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
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.