📄 traintest_newfinal.m
字号:
clear
from=5;
length=8;
%rez=100;
% gray-level shift
u=0; % add noise
lowin=0.1; highin=0.9;
lowout=0.1; highout=0.9;
% target creation
T1=[0 1 1 0;0 1 1 0;0 1 1 0;0 1 1 0];
T2=[1 1 0 0;1 1 0 0;1 1 0 0;1 1 0 0];
T3=[1 1 1 0;1 1 1 0;1 1 1 0;1 1 1 0];
T4=[0 1 1 1;0 1 1 1;0 1 1 1;0 1 1 1];
T5=[1 0 0 0;1 0 0 0;1 0 0 0;1 0 0 0];
T6=[0 0 0 1;0 0 0 1;0 0 0 1;0 0 0 1];
T7=[1 0 1 0;1 0 1 0;1 0 1 0;1 0 1 0];
T8=[0 1 0 1;0 1 0 1;0 1 0 1;0 1 0 1];
T9=[1 0 0 1;1 0 0 1;1 0 0 1;1 0 0 1];
T10=[0 0 1 1;0 0 1 1;0 0 1 1;0 0 1 1];
% read images
for i = from:length
data1{i-4} = imread(['C:\images\f1\' num2str(i) '.tif']);
data1{i-4} = imnoise(data1{i-4},'salt & pepper',u);
data1{i-4} = imadjust(data1{i-4},[lowin highin],[lowout highout]);
%temp = imresize(temp, [rez rez]);
%data1(i-4,:) = temp(:);
end;
for i = from:length
data2{i-4} = imread(['C:\images\f2\' num2str(i) '.tif']);
data2{i-4} = imnoise(data2{i-4},'salt & pepper',u);
data2{i-4} = imadjust(data2{i-4},[lowin highin],[lowout highout]);
%temp = imresize(temp, [rez rez]);
%data2(i-4,:) = temp(:);
end;
for i = from:length
data3{i-4} = imread(['C:\images\f3\' num2str(i) '.tif']);
data3{i-4} = imnoise(data3{i-4},'salt & pepper',u);
data3{i-4} = imadjust(data3{i-4},[lowin highin],[lowout highout]);
%temp = imresize(temp, [rez rez]);
%data3(i-4,:) = temp(:);
end;
for i = from:length
data4{i-4} = imread(['C:\images\f4\' num2str(i) '.tif']);
data4{i-4} = imnoise(data4{i-4},'salt & pepper',u);
data4{i-4} = imadjust(data4{i-4},[lowin highin],[lowout highout]);
%temp = imresize(temp, [rez rez]);
%data4(i-4,:) = temp(:);
end;
for i = from:length
data5{i-4} = imread(['C:\images\f5\' num2str(i) '.tif']);
data5{i-4} = imnoise(data5{i-4},'salt & pepper',u);
data5{i-4} = imadjust(data5{i-4},[lowin highin],[lowout highout]);
%temp = imresize(temp, [rez rez]);
%data5(i-4,:) = temp(:);
end;
for i = from:length
data6{i-4} = imread(['C:\images\f6\' num2str(i) '.tif']);
data6{i-4} = imnoise(data6{i-4},'salt & pepper',u);
data6{i-4} = imadjust(data6{i-4},[lowin highin],[lowout highout]);
%temp = imresize(temp, [rez rez]);
%data6(i-4,:) = temp(:);
end;
for i = from:length
data7{i-4} = imread(['C:\images\f7\' num2str(i) '.tif']);
data7{i-4} = imnoise(data7{i-4},'salt & pepper',u);
data7{i-4} = imadjust(data7{i-4},[lowin highin],[lowout highout]);
%temp = imresize(temp, [rez rez]);
%data7(i-4,:) = temp(:);
end;
for i = from:length
data8{i-4} = imread(['C:\images\f8\' num2str(i) '.tif']);
data8{i-4} = imnoise(data8{i-4},'salt & pepper',u);
data8{i-4} = imadjust(data8{i-4},[lowin highin],[lowout highout]);
%temp = imresize(temp, [rez rez]);
%data8(i-4,:) = temp(:);
end;
for i = from:length
data9{i-4} = imread(['C:\images\f9\' num2str(i) '.tif']);
data9{i-4} = imnoise(data9{i-4},'salt & pepper',u);
data9{i-4} = imadjust(data9{i-4},[lowin highin],[lowout highout]);
%temp = imresize(temp, [rez rez]);
%data9(i-4,:) = temp(:);
end;
for i = from:length
data10{i-4} = imread(['C:\images\f10\' num2str(i) '.tif']);
data10{i-4} = imnoise(data10{i-4},'salt & pepper',u);
data10{i-4} = imadjust(data10{i-4},[lowin highin],[lowout highout]);
%temp = imresize(temp, [rez rez]);
%data10(i-4,:) = temp(:);
end;
%-------------------\\\Train test set///----------------
hd=10;
lr=.25;
ep=20;
load wintface;load zintface;
WX=winit;ZX=zinit;
save wq WX;
save zq ZX;
%--------------------------
%WX=rand(900+1,10);
%ZX=rand(10+1,4);
%winit=WX;
%zinit=ZX;
%save wint winit;
%save zint zinit;
%save wq WX;
%save zq ZX;
%------------------------
%SS = who('-file','zq');
%TT = who('-file','wq');
%if SS{1}=='Z'
% load zq;
% ZX=Z;
% save zq ZX;
%end;
%if TT{1}=='W'
% load wq;
% WX=W;
% save wq WX;
%end;
tic
[WX,ZX,O1,E1]=msnn2(T1,data1,hd,lr,ep);
[WX,ZX,O2,E2]=msnn2(T2,data2,hd,lr,ep);
[WX,ZX,O3,E3]=msnn2(T3,data3,hd,lr,ep);
[WX,ZX,O4,E4]=msnn2(T4,data4,hd,lr,ep);
[WX,ZX,O5,E5]=msnn2(T5,data5,hd,lr,ep);
[WX,ZX,O6,E6]=msnn2(T6,data6,hd,lr,ep);
[WX,ZX,O7,E7]=msnn2(T7,data7,hd,lr,ep);
[WX,ZX,O8,E8]=msnn2(T8,data8,hd,lr,ep);
[WX,ZX,O9,E9]=msnn2(T9,data9,hd,lr,ep);
[WX,ZX,O10,E10]=msnn2(T10,data10,hd,lr,ep);
toc
timerTestSet=toc;
out_test1 = O1(1,:);
out_test2 = O2(1,:);
out_test3 = O3(1,:);
out_test4 = O4(1,:);
out_test5 = O5(1,:);
out_test6 = O6(1,:);
out_test7 = O7(1,:);
out_test8 = O8(1,:);
out_test9 = O9(1,:);
out_test10 = O10(1,:);
outTest = [out_test1;out_test2;out_test3;out_test4;...
out_test5;out_test6;out_test7;out_test8;...
out_test9;out_test10];
save N;
% Plot Error Descent
%EgraphTrain = [E1,E2,E3,E4];
%plot(EgraphTrain);
%xlabel('Epochs');
%ylabel('Training Error of Training Set');
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -