-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDIY_ELM.m
95 lines (91 loc) · 3.16 KB
/
DIY_ELM.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
% DIY_ELM
%% setting 1
acc = zeros(1,9);
for SL = 2:10
clear -regexp [^SL,^acc]
clc
load A.mat
load index.mat
Source=A{1,1};
Target=A{1,SL};
Source_label=(vec2ind(index{1,1}))';
Target_label=(vec2ind(index{1,SL}))';
%¹éÒ»»¯
Source=Source./repmat(sqrt(sum(Source.^2,1)),size(Source,1),1);
Target=Target./repmat(sqrt(sum(Target.^2,1)),size(Target,1),1);
for cishu=1:10
clear max;
clear result;
% ELM
error2=0;
counter=0;
class_num=[1;5;10;15;20];
ActivationFunction='radbas';
for t=1:5
Hnumbt=class_num(t,1);
for v=0:20
counter=counter+1;
Cv=10^v;
try
[TrainingAccuracy, TestingAccuracy] = fast_elm(Source,Source_label,Target,Target_label,1, Hnumbt, ActivationFunction,Cv);
catch
error2 = error2 +1;
TestingAccuracy =0;
end
testaccracy=TestingAccuracy;
result(counter,1)=Hnumbt;
result(counter,2)=v;
result(counter,3)=TestingAccuracy;
end
end
[max,index]=max(result(:,3));
maxpara=result(index,:);
newresult(cishu,:)=maxpara;
end
acc(SL-1) = max;
end
%% setting 2
acc = zeros(1,9);
for SL = 2:10
clear -regexp [^SL,^acc]
clc
load A.mat
load index.mat
Source = A{1,SL-1};
Target = A{1,SL};
Source_label=(vec2ind(index{1,SL-1}))';
Target_label=(vec2ind(index{1,SL}))';
%¹éÒ»»¯
Source=Source./repmat(sqrt(sum(Source.^2,1)),size(Source,1),1);
Target=Target./repmat(sqrt(sum(Target.^2,1)),size(Target,1),1);
for cishu=1:10
clear max;
clear result;
% ELM
error2=0;
counter=0;
class_num=[1;5;10;15;20];
ActivationFunction='radbas';
for t=1:5
Hnumbt=class_num(t,1);
for v=0:20
counter=counter+1;
Cv=10^v;
try
[TrainingAccuracy, TestingAccuracy] = fast_elm(Source,Source_label,Target,Target_label,1, Hnumbt, ActivationFunction,Cv);
catch
error2 = error2 +1;
TestingAccuracy =0;
end
testaccracy=TestingAccuracy;
result(counter,1)=Hnumbt;
result(counter,2)=v;
result(counter,3)=TestingAccuracy;
end
end
[max,index]=max(result(:,3));
maxpara=result(index,:);
newresult(cishu,:)=maxpara;
end
acc(SL-1) = max;
end