码迷,mamicode.com
首页 > 其他好文 > 详细

自联想神经网络

时间:2019-01-17 00:36:27      阅读:176      评论:0      收藏:0      [点我收藏+]

标签:rev   toolbox   data   tran   神经网络   div   apply   mat   nbsp   

第一篇博文,先贴代码慢慢改……

%------------------------AANN by NNtoolbox----------------------------------
tran_fun_type ={‘logsig‘;‘purelin‘;‘logsig‘;‘purelin‘};
bn_l = 1;%
if bn_l<10
    lh = (2+2*bn_l); 
else
    lh = bn_l;
end 
net = feedforwardnet([lh,bn_l,lh]);
%net.trainParam.epochs=1000%

for i=1:size(tran_fun_type,1)
    net.layers{i}.transferFcn = tran_fun_type{i};
end

net = train(net,data_1,data_1);

input = mapminmax(‘apply‘,data_1,net.inputs{1}.processSettings{1});
L1 = logsig(net.IW{1,1} * input + net.B{1});
L2 = purelin( net.LW{2,1} * L1 +  net.B{2});
L3 = logsig(net.LW{3,2} * L2 +  net.B{3});
L4 = purelin(net.LW{4,3} * L3 +  net.B{4});
OUT = mapminmax(‘reverse‘,L4,net.outputs{4}.processSettings{1});

data_resc1_1 = sim(net,data_1);

data_resc1 =  mapminmax(‘reverse‘,data_resc1_1,traM)

dt = mapminmax(‘reverse‘,data_1,traM);

for i = 1:size(data_1,1)
    fig_hdl = figure(i);
    y = data_1(i,:)‘;
    x = data_resc1_1(i,:)‘;
    FIT_CUR = polyfit(x,y,1);
    r_ = corrcoef(x,y);
    y_ = polyval(FIT_CUR,x);
    plot(x,y,‘k+‘,x,y_,‘r‘);
    title(strcat(‘R:‘,num2str(r_(2,1)),‘  a:‘,num2str(FIT_CUR(1)),‘  b:‘, num2str(FIT_CUR(2)) ));
    saveas(fig_hdl,strcat(‘AANNfit_cur‘,num2str(i)),‘jpg‘);
end
%--------------------------NLPCA toolbox------------------------------------------
[pc net network] = nlpca(data_1, bn_l);
data_resc2_1 = nlpca_get_data(net,pc);

for i = 1:size(data_1,1)
    fig_hdl = figure(i);
    y = data_1(i,:)‘;
    x = data_resc2_1(i,:)‘;
    FIT_CUR = polyfit(x,y,1);
    r_ = corrcoef(x,y);
    y_ = polyval(FIT_CUR,x);
    plot(x,y,‘k+‘,x,y_,‘r‘);
    title(strcat(‘R:‘,num2str(r_(2,1)),‘  a:‘,num2str(FIT_CUR(1)),‘  b:‘, num2str(FIT_CUR(2)) ));
    saveas(fig_hdl,strcat(‘NLPCAfit_cur‘,num2str(i)),‘jpg‘);
end

%--------------------------PCA ------------------------------------------
[coeff,score,latent,tsquared,explained,mu] = pca(data_1‘)
tar=bn_l;
data_resc3_1 = score(:,1:tar)*coeff(:,1:tar)‘ + repmat(mu,size(data_1,2),1);

for i = 1:size(data_1,1)
    fig_hdl = figure(i);
    y = data_1(i,:)‘;
    x = data_resc3_1(:,i);
    FIT_CUR = polyfit(x,y,1);
    r_ = corrcoef(x,y);
    y_ = polyval(FIT_CUR,x);
    plot(x,y,‘k+‘,x,y_,‘r‘);
    title(strcat(‘R:‘,num2str(r_(2,1)),‘  a:‘,num2str(FIT_CUR(1)),‘  b:‘, num2str(FIT_CUR(2)) ));
    saveas(fig_hdl,strcat(‘PCAfit_cur‘,num2str(i)),‘jpg‘);
end

 

自联想神经网络

标签:rev   toolbox   data   tran   神经网络   div   apply   mat   nbsp   

原文地址:https://www.cnblogs.com/PProtector/p/10280081.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!