Why the results are different every time using the code of Nonnegative matrix factorization ?

7 次查看(过去 30 天)
I use this code to deal the same EMG data ,but every time the results are different ,what's wrong of the code ? how to change the code?
I think I follwe the 'help' about the nnmf.
K=5;
opt = statset('MaxIter',100,'Display','off');
[W0,H0] = nnmf(EMG,K,'replicates',10,'options',opt,'algorithm','mult');
opt = statset('Maxiter',10000,'Display','final');
[W,H] = nnmf(EMG,K,'w0',W0,'h0',H0, 'options',opt,'algorithm','als');

回答(1 个)

Steven Lord
Steven Lord 2020-9-15
From the documentation page for the nnmf function: "The factorization uses an iterative method starting with random initial values for W and H." If you want each call to nnmf to use the same initial values, specify w0 and h0 in the options structure, specify Streams in the options structure, and/or initialize the random number generator to a known state using rng before each call to nnmf.
  2 个评论
Steven Lord
Steven Lord 2020-9-15
More from the documentation page: if A is an n-by-m matrix and k is the second input, pass "An n-by-k matrix to be used as the initial value for W." in as w0 and "A k-by-m matrix to be used as the initial value for H." as h0. The last block of code in the second example shows the syntax for how to do that.
If you're asking which particular n-by-k and k-by-m matrices you should specify, that depends on your A matrix. Ideally you want w0 and h0 that are "close to" the actual solution. You'll have an easier time finding Mount Everest if you start somewhere in the Himalayas than if you started in the middle of the ocean.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Dimensionality Reduction and Feature Extraction 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by