?? hzh_nn_ro.m
字號:
%%%%用于對王鳳利的數據進行分類,數據在wangfl_data中,
%其中
% aa 為 earlyrub aa1為雙通道的前半部分,aa2為雙通道的后半部分
% bb 為 loose bb1\bb2
% cc 為 misalignment cc1\cc2
% dd 為 rub dd1\dd2 用雙通道的后半部分好象效果好一點。
% prepare to use the data of bb\cc\dd\ for test the neural network of time series.
%===================================================================
% 長度為256,兩個通道分別試驗一下;長度為512,兩個通道分別試驗一下
%==================================================================
close all
clc
load roto_data_my
[aa,xmin,xmax]=scale(org_budzh,0,1);
[bb,xmin,xmax]=scale(org_budzhsd,0,1);
[cc,xmin,xmax]=scale(org_buph,0,1);
%for i=1:8 %%求取 rub dd為雙通道的后半部分 每一段為256點,共8段
% dd1_rub(i,:)=dd1(256*(i-1)+1:256*i)';
% dd2_rub(i,:)=dd2(256*(i-1)+1:256*i)';
% end
% figure;
% for i=1:8
% subplot(8,1,i)
% plot(dd2_rub(i,:))
% end
% for i=1:8 %%求取 loose bb為雙通道的后半部分 每一段為512點,共8段
% bb1_loose(i,:)=bb1(256*(i-1)+1:256*i)';
% bb2_loose(i,:)=bb2(256*(i-1)+1:256*i)';
% end
% figure;
% for i=1:8
% subplot(8,1,i)
% plot(bb2_loose(i,:))
% end
% for i=1:8 %%求取 misalignment cc為雙通道的后半部分 每一段為512點,共8段
% cc1_misali(i,:)=cc1(256*(i-1)+1:256*i)';
% cc2_misali(i,:)=cc2(256*(i-1)+1:256*i)';
% end
% figure;
% for i=1:8
% subplot(8,1,i)
% plot(cc2_misali(i,:))
%end
%==========================用dd1_rub作模式樣本
nlag=12;
biaozhun=cc(1:512); % 標準模式
%for i=1:8
%ceshi=cc(1024*(i-1)+1:1024*i); % 測試模式
%tmp=[biaozhun',ceshi'];
%[x0,train,test]=tsgenf_hzh(tmp,2048,1024,1,nlag);
[x0,train,test]=tsgenf_hzh(biaozhun,512,256,1,nlag);
%------------******-----------------
% W1 : Input-to-hidden layer weights. The matrix dimension is
% dim(W1) = [(# of hidden units) * (inputs + 1)] (the 1 is due to the bias)
% W2 : hidden-to-output layer weights.
% dim(W2) = [(outputs) * (# of hidden units + 1)]
rand('seed',0);
W1 = rand(6,nlag+1)-0.5; % Weights to hidden layer 權值加減-0。5 +0。5有助于預測的準確性
W2 = rand(1,7)+0.5; % Weights to output
NetDef = ['HHHHHH'
'L-----'];
maxiter = 1000;
stop_crit = 1e-6;
lambda=1;
D=1;%加規格化項有助于快速收斂,在其值為 0.031 時均方誤差結果理想, DD=DI.
trparms=[maxiter stop_crit lambda D];
[W1,W2,PI_vector,iter,lambda]=marq(NetDef,W1,W2,train(:,1:nlag)',train(:,nlag+1)',trparms);
% ----------- Validate Network -----------
for i=1:8
ceshi=cc(256*(i-1)+1:256*i); % 測試模式
tmp=[biaozhun(1:256)',ceshi'];
[x0,train,test]=tsgenf_hzh(tmp,512,256,1,nlag);
[Y_sim,E] = nneval(NetDef,W1,W2,test(:,1:nlag)',test(:,nlag+1)',1);
% ----------- Plot Cost function -----------
figure
plot(test(:,nlag+1)')
figure
semilogy(PI_vector)
title('Criterion evaluated after each iteration')
xlabel('Iteration (epoch)')
ylabel('Criterion')
grid
MSE(i)=sum(E.*E)/length(test)
SNR(i)=20*log10(sum(ceshi.*ceshi)/sum(E.*E))
end
MEAN=mean(SNR)
STD=std(SNR)
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -