forked from hiroyuki-kasai/NMFLibrary
-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.m
42 lines (31 loc) · 1.02 KB
/
demo.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
function demo()
%
% demonstration file for NMFLibrary.
%
% This file illustrates how to use this library.
% This demonstrates multiplicative updates (MU) algorithm and
% hierarchical alternative least squares (Hierarchical ALS) algorithm.
%
% This file is part of NMFLibrary.
%
% Created by H.Kasai on Apr. 05, 2017
clc;
clear;
close all;
%% generate synthetic data of (mxn) matrix
m = 500;
n = 100;
V = rand(m,n);
%% Initialize of rank to be factorized
rank = 5;
%% perform factroization
% MU
options.alg = 'mu';
[w_nmf_mu, infos_nmf_mu] = nmf_mu(V, rank, options);
% Hierarchical ALS
options.alg = 'hals';
[w_nmf_hals, infos_nmf_hals] = nmf_als(V, rank, options);
%% plot
display_graph('epoch','cost', {'MU', 'HALS'}, {w_nmf_mu, w_nmf_hals}, {infos_nmf_mu, infos_nmf_hals});
display_graph('time','cost', {'MU', 'HALS'}, {w_nmf_mu, w_nmf_hals}, {infos_nmf_mu, infos_nmf_hals});
end