⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 autoenc_dd.m

📁 模式识别工具箱,希望对大家有用!
💻 M
字号:
%AUTOENC_DD Auto-Encoder data description.% %       W = autoenc_dd(A,fracrej,N)% % Train an Auto-Encoder network with N hidden units.% % See also datasets, mappings, dd_roc% Copyright: D. Tax, R.P.W. Duin, davidt@ph.tn.tudelft.nl% Faculty of Applied Physics, Delft University of Technology% P.O. Box 5046, 2600 GA Delft, The Netherlandsfunction [W,out] = autoenc_nn(a,fracrej,N)if nargin < 3 | isempty(N), N = 5; endif nargin < 2 | isempty(fracrej), fracrej = 0.05; endif nargin < 1 | isempty(a) % empty nndd  W = mapping(mfilename,{fracrej,N});  returnendif isa(fracrej,'double')           %training  if ~isa(a,'dataset')              %train on training set    error('I need a dataset to train');  end  a = target_class(a);     % make sure a is an OC dataset  [nlab,lablist,m,k,c] = dataset(a);  [nrx,dim] = size(+a);  minmax = [min(+a)' max(+a)'];  net = newff(minmax,[N dim],{'tansig','purelin'},'trainlm');  net = init(net);  net.trainParam.show = inf;  net.trainParam.lr = 0.01;  net.trainParam.goal = 1e-5;  net = train(net,+a',+a');  % obtain the threshold:  aout = sim(net,+a');  d = sum((a-aout').^2,2);  thr = -threshold(-d,fracrej);  %and save all useful data:  W.net = net;  W.scale = mean(d);  W.threshold = thr;  W = mapping(mfilename,W,str2mat('target','outlier'),k,c);else                               %testing  [W,classlist,type,k,c] = mapping(fracrej);  % unpack  [nlab,lablist,m,k,c,p] = dataset(a);  %compute distance:  out = sim(W.net,+a')';  out = [sum((a-out).^2,2) ones(m,1)*W.threshold];  % map to probability  newout = dist2dens(out,W.scale);  W = dataset(newout,getlab(a),classlist,p,lablist);endreturn

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -