This repository gives a quick tutorial on implementing Canonical Polyadic tensor decomposition in Python, including a brief introduction to Tensor decomposition. However, the main purpose of this notebook is to focus on the implementation of tensor decomposition in Python. In line with these objectives, we will implement tensor decomposition using two libraries available in Python (TensorLy and tensortools) and a simple implementation of Tensor Decomposition with Numpy (via alternating optimization). Furthermore, the result of these three approaches are compared in terms of reconstruction error and execution time.
- Tensor Decomposition
- Implementation
- TensorLy
- tensortools
- Numpy
- Results and Comparison
An attempt to partially reproducing the result of this paper's figure 2.
For the complete tutorial click here, and for the extended version click here.
- Numpy
- Matplotlib
- Seaborn
- TensorLy == 0.4.3
- tensortools
Of course you can simply install the dependencies and run the code in your own Python environment. But another option to run the notebook in a docker container:
- Clone the repository
git clone https://github.com/mohammadbashiri/tensor-decomposition-in-python.git
- Navigate to the project directory
cd tensor-decomposition-in-python
- Build the docker image
docker build -t ds .
- Create a container from the created image
docker run -p 7890:8888 -v $(pwd):/project --name ds_container -d --rm ds
- By entering
localhost:7890
in your browser you can open the current directory inside jupyterlab and run the notebooks
I would like to thank Annika Thierfelder for her constructive feedback on the content.
- Tuncer, Yalcin, Murat M. Tanik, and David B. Allison. "An overview of statistical decomposition techniques applied to complex systems." Computational statistics & data analysis 52.5 (2008): 2292–2310.
- Cichocki, Andrzej, et al. "Tensor decompositions for signal processing applications: From two-way to multiway component analysis." IEEE Signal Processing Magazine 32.2 (2015): 145–163.
- Williams, Alex H., et al. "Unsupervised Discovery of Demixed, Low-Dimensional Neural Dynamics across Multiple Timescales through Tensor Component Analysis." Neuron (2018).
- Talk by Tamara Kolda
- Tutorial by Alex Williams: part 1, part 2