-
大小: 4KB文件類型: .m金幣: 1下載: 0 次發布日期: 2021-05-23
- 語言: Matlab
- 標簽: Deep-Semi-NM??matlab??
資源簡介
該代碼是用matlab編寫的,為深度半非負矩陣分解算法,用于人臉識別的。
代碼片段和文件信息
function?[?Z?H?dnorm?]?=?deep_seminmf?(?X?layers?varargin?)
%?Process?optional?arguments
pnames?=?{?...
????‘z0‘?‘h0‘?‘bUpdateH‘?‘bUpdateLastH‘?‘maxiter‘?‘TolFun‘?...
????‘verbose‘?‘bUpdateZ‘?‘cache‘?‘gnd‘?...
};
X?=?bsxfun(@rdivideXsqrt(sum(X.^21)));
num_of_layers?=?numel(layers);
Z?=?cell(1?num_of_layers);
H?=?cell(1?num_of_layers);
dflts??=?{0?0?1?1?500?1e-5?1?1?1?0};
[z0?h0?bUpdateH?bUpdateLastH?maxiter?tolfun?verbose?bUpdateZ?cache?gnd]?=?...
????????internal.stats.parseArgs(pnamesdfltsvarargin{:});
if??~iscell(h0)
????for?i_layer?=?1:length(layers)
????????if?i_layer?==?1
????????????%?For?the?first?layer?we?go?linear?from?X?to?Z*H?so?we?use?id
????????????V?=?X;
????????else?
????????????V?=?H{i_layer-1};
????????end
????????
????????if?verbose
????????????display(sprintf(‘Initialising?layer?#%d?with?k=%d?with?size(V)=%s...‘?i_layer?layers(i_layer)?mat2str(size(V))));
????????end
????????if?~iscell(z0)
????????????%?For?the?later?layers?we?use?nonlinearities?as?we?go?from
????????????%?g(H_{k-1})?to?Z*H_k
????????????[Z{i_layer}?H{i_layer}?~]?=?...
?????????????????seminmf(V?...
?????????????????????layers(i_layer)?...
?????????????????????‘maxiter‘?maxiter?...
?????????????????????‘bUpdateH‘?true?‘bUpdateZ‘?bUpdateZ?‘verbose‘?verbose?‘save‘?cache?‘fast‘?1);?
????????else
????????????display(‘Using?existing?Z‘);
????????????[Z{i_layer}?H{i_layer}?~]?=?...
?????????????????seminmf(V?...
?????????????????????layers(i_layer)?...
?????????????????????‘maxiter‘?1?...
?????????????????????‘bUpdateH‘?true?‘bUpdateZ‘?0?‘z0‘?z0{i_layer}?‘verbose‘?verbose?‘save‘?cache?‘fast‘?1);?
????????end
????end
else
????Z=z0;
????H=h0;
????
????if?verbose
????????display(‘Skipping?initialization?using?provided?init?matrices...‘);
????end
end
dnorm0?=?cost_function(X?Z?H);
dnorm?=?dnorm0?+?1;
if?verbose
????display(sprintf(‘#%d?error:?%f‘?0?dnorm0));
end
%%?Error?Propagation
if?verbose
????display(‘Finetuning...‘);
end
H_err?=?cell(1?num_of_layers);
for?iter?=?1:maxiter??
????H_err{numel(layers)}?=?H{n
- 上一篇:Semi-NMF源代碼
- 下一篇:chan算法時差定位的一種使用算法
評論
共有 條評論