GithubHelp home page GithubHelp logo

isabella232 / tensorly Goto Github PK

View Code? Open in Web Editor NEW

This project forked from quansight/tensorly

0.0 0.0 0.0 1.01 MB

TensorLy: Tensor Learning in Python.

Home Page: http://tensorly.org

License: Other

Makefile 0.17% Shell 0.42% Python 99.42%

tensorly's Introduction

image

image

image

image

image

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.


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:

pip install -U tensorly

.. code:

conda install -c tensorly tensorly

**Development

(from git)**

.. code:

# clone the repository
git clone https://github.com/te
cd tensorly
# Install in editable mode with
pip install -e .

nsorly/tensorly

-e or, equivalently, --editable

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.


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:

pytest -v tensorly

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

TENSORLY_BACKEND='numpy' pytest -v tensorly

Quickstart

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

import tensorly as tl
import numpy as np


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

Applying tensor decomposition is easy:

from tensorly.decomposition import tucker
# Apply Tucker decomposition 
core, factors = tucker(tensor, rank=[2, 2, 2])
# Reconstruct the full tensor from the decomposed form
tl.tucker_to_tensor(core, factors) 

You can change the backend to perform computation with a different framework. Note that using MXNet, PyTorch, TensorFlow 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:

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

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!


Citing

If you use TensorLy in an academic paper, please cite:

@article{tensorly,
  author    = {Jean Kossaifi and Yannis Panagakis and Anima Anandkumar and Maja Pantic},
  title     = {TensorLy: Tensor Learning in Python},
  journal   = {CoRR},
  volume    = {abs/1610.09555},
  year      = {2018},
}

tensorly's People

Contributors

jeankossaifi avatar zongyi-li avatar samjohannes avatar akiskefalas avatar tvpavan avatar shivangim avatar thomasdelteil avatar alexstasik avatar curtlh avatar stsievert avatar shuo-zhou avatar soumith avatar krinsman avatar eriche7133 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.