TensorLy, with MXNet Backend

machine-learning TensorLy MXNet


The goal of TensorLy is to make tensor operations easy and accessible. I originally developed it to have minimum dependency and depend only on NumPy, SciPy and optionally on Matplotlib for plotting. However, as Deep Learning becomes more ubiquitous, we need better tools to i) combine tensor methods and Deep Learning and ii) run the algorithms at scale, on several machines and both CPU and GPU. It so happens that MXNet, in addition to shining in both of these areas, has an NDArray structure that is very similar to NumPy and aims at feature parity with it. Furthermore, its ability to use to define deep networks imperatively made it a prime candidate.

I therefore refactored TensorLy to accept both MXNet and NumPy as backends, which now allows to run tensor methods on CPU and GPU transparently and to seemlessly combine them with Deep Learning using MXNet's Gluon interface (for a great tutorial on Gluon and deep learning, check out this interactive book).

Here is a quick guide on getting started with the new version of TensorLy.

Installation

Pre-requisite

If you don't already have Python I recommend you use Anaconda (choose Python 3, it's 2017). Then install MXNet.

Install with pip

We want the latest version of MXNet, and the latest version of TensorLy:

pip install --pre mxnet
pip install -U tensorly

Install from source

Install MXNet from source

To install from sources, you first want to clone the repository:

git clone --recursive https://github.com/apache/incubator-mxnet.git
cd mxnet

Next, make the shared library:

OSX Linux
cp make/osx.mk ./config.mk
make -j$(sysctl -n hw.ncpu)
make -j $(nproc)

Install the python binding:

cd python
pip install -e .

Install TensorLy from source

git clone https://github.com/tensorly/tensorly
cd tensorly
pip install -e .

That's it, you're ready to go!

Checking all is good

You can now check everything is working as expected in Python:

>>> import tensorly as tl
Using mxnet backend.
>>> print(tensorly.__version__)
'0.2.0'

What's next

For documentation, check the documentation.

For source code, head to TensorLy's github repository.

For examples of use, check out the jupyter Notebooks.

Leave a comment