SkillAgentSearch skills...

PyLegendreDecomposition

This project is a Python implementation of the Legendre decomposition of nonnegative tensors and many-body approximation.

Install / Use

/learn @kojima-r/PyLegendreDecomposition
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

Legendre decomposition implementation

GitHub Pages

This project contains the following three python implementation of Legendre decomposition and Many-body Approximation for Non-negative Tensors.

  • Naïve implementation:

    • straightforward implementation by using SciPy/NumPy
  • Faster implementation:

    • Vectorization using equivalent NumPy code
  • GPU implementation:

    • Using CuPy to further change NumPy code to GPU-executable code
    • The same method is used for the Faster implementation and GPU, and switching is done by enabling or disabling the GPU.

Installation

Installation of pyLegendreDecomposition

pip install git+https://github.com/kojima-r/pyLegendreDecomposition.git

Installation of Cupy

pip install  cupy-cuda12x

Please change the cuda12x as appropriate. See the cupy manual for details.

https://docs.cupy.dev/en/stable/install.html

Simple Usage

from legendre_decomp import LD
all_history_kl,scaleX,Q,Hq = LD(X,order=2)
  • X: a original input tensor
  • order: an order parameter of many-body approximation
  • all_history_kl: KL divergence history
  • scaleX: Scaled X tensor
  • Q: Q tensor
  • theta: Theta

See API reference of LD for details.

Documents / notebook

API reference

Benchmark results

Colaboratory notebook

Project structure

  • legendre_decomp: Main module
  • docs: Documentation
  • tests: Functional tests
  • scripts: Benchmark scripts
  • notebooks: Benchmark Jupyter Notebooks

Reference

Many-body Approximation for Non-negative Tensors: https://arxiv.org/abs/2209.15338

@article{ghalamkari2024many,
  title={Many-body Approximation for Non-negative Tensors},
  author={Ghalamkari, Kazu and Sugiyama, Mahito and Kawahara, Yoshinobu},
  journal={Advances in Neural Information Processing Systems},
  volume={36},
  year={2024}
}

Legendre Decomposition for Tensors: https://arxiv.org/abs/1802.04502

@article{sugiyama2018legendre,
  title={Legendre decomposition for tensors},
  author={Sugiyama, Mahito and Nakahara, Hiroyuki and Tsuda, Koji},
  journal={Advances in Neural Information Processing Systems},
  volume={31},
  year={2018}
}

How to build documentation (need sphinx)

Installation of sphinx modules

pip install sphinx-autoapi
pip install pydata-sphinx-theme

Building documents

sphinx-build -M html docs/source docs/build

or

cd docs
make html

The documentation including installation manual can then be accessed from docs/build/html/index.html

View on GitHub
GitHub Stars8
CategoryDevelopment
Updated2mo ago
Forks0

Languages

Jupyter Notebook

Security Score

85/100

Audited on Jan 7, 2026

No findings