Why the results are different every time using the code of Nonnegative matrix factorization ?
조회 수: 4 (최근 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');
댓글 수: 0
답변 (1개)
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
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.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!