Giter Club home page Giter Club logo

cunmf's Introduction

cuNMF - Nonnegative Matrix Factorization using CUDA

License: MIT GitHub Release DOI

Version: 1.0.0

Copyright: Maximilian Behr

License: The software is licensed under under MIT. See LICENSE for details.

cuNMF is a CUDA library implementing multiplicative update rules for the nonnegative matrix factorization $X\approx WH$, using the $\beta$-divergence as an error measure.

cuNMF supports real single and double precision matrices.

Available Functions

General Functions

int cunmf_info_create(cunmf_info* info);
int cunmf_info_destroy(cunmf_info info);

Single Precision Functions

int cunmf_options_screate(cunmf_options* opt);
int cunmf_options_sdestroy(cunmf_options opt);

int cunmf_sMUbeta_buffersize(int m, int n, int k, double beta, size_t* bufferSize);
int cunmf_sMUbeta(int m, int n, int k, double beta, const float* X, void* buffer, const cunmf_options opt, float* W, float* H, cunmf_info info);

Double Precision Functions

int cunmf_options_dcreate(cunmf_options* opt);
int cunmf_options_ddestroy(cunmf_options opt);

int cunmf_dMUbeta_buffersize(int m, int n, int k, double beta, size_t* bufferSize);
int cunmf_dMUbeta(int m, int n, int k, double beta, const float* X, void* buffer, const cunmf_options opt, float* W, float* H, cunmf_info info);

Algorithm

cuNMF implements the multiplicative update rules to minimize the $\beta$-divergence for the nonnegative matrix factorization $X\approx W H$, where $X$ is of size $m\times n$, $W$ is of size $m\times k$ and $H$ is of size $k\times n$.

In more details, we consider the optimization problem

$$\min\limits_{W \geq \epsilon, H \geq \epsilon} D_{\beta}(X || WH)=\sum_{i=1}^{m}\sum_{j=1}^{n} d_{\beta}(X_{i,j},(WH)_{i,j})$$

where $\epsilon$ is a small nonegative constant and the $\beta$-divergence $d_{\beta}(x,y)$ is given by

$$d_{\beta}(x,y)=\left\{ \begin{array}{ll} \frac{x}{y} -\log(\frac{x}{y}) -1 & \beta = 0, \\\ x\log(\frac{x}{y}) -x + y & \beta = 1, \\\ \frac{1}{\beta(\beta-1)}(x^{\beta} + (\beta-1)y^{\beta}-\beta xy^{\beta-1}) & \textrm{otherwise}. \end{array} \right.$$

The case $\beta=0$ gives the Itakura–Saito divergence, $\beta = 1$ gives the Kullback–Leibler divergence, and $\beta=2$ gives the Frobenius norm distance $\frac{1}{2}||\cdot||_F^2$. For more details on the multiplicative update rule see Theorem 8.8 and Theorem 8.9 in

Gillis, Nicolas. Nonnegative matrix factorization. Society for Industrial and Applied Mathematics, 2020.

Installation

Prerequisites:

  • CMake >= 3.23
  • CUDA >= 11.4.2
  mkdir build && cd build
  cmake ..
  make
  make install

Usage and Examples

The multiplicate update algorithm is an iterative ones. The initial iterates $W_0$ and $H_0$ must be nonnegative. The parameter $k$ (number of columns of $W$ / rows of $H$) must be specified by the user. The user can also specifiy stopping criteria based on the

  • number of iterations (maxiter)
  • computational time (maxtime)
  • relative change of the iterates $W$ and $H$ (tol_relchange_WH)
  • relative change of the objective $D_{\beta}$ (tol_relchange_objective).

See example_cunmf_MUbeta.cu for an example using double precision data.

cunmf's People

Contributors

maximilianbehr avatar

Stargazers

 avatar  avatar  avatar

Watchers

 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.