summaryrefslogtreecommitdiffstats
path: root/SD-VBS/benchmarks/svm/src/matlab/getAlphaFromTrainSet.m
diff options
context:
space:
mode:
Diffstat (limited to 'SD-VBS/benchmarks/svm/src/matlab/getAlphaFromTrainSet.m')
-rw-r--r--SD-VBS/benchmarks/svm/src/matlab/getAlphaFromTrainSet.m58
1 files changed, 58 insertions, 0 deletions
diff --git a/SD-VBS/benchmarks/svm/src/matlab/getAlphaFromTrainSet.m b/SD-VBS/benchmarks/svm/src/matlab/getAlphaFromTrainSet.m
new file mode 100644
index 0000000..bd2bec7
--- /dev/null
+++ b/SD-VBS/benchmarks/svm/src/matlab/getAlphaFromTrainSet.m
@@ -0,0 +1,58 @@
1function [a,b,C,d,dim,e,eps,a_result,b_result,X,tolerance,Y,ret]=getAlphaFromTrainSet(N, d16trn_1, d16trn_2, Iterations)
2
3
4tolerance=0.001;
5C=0.05;
6d = -1;
7dim=256;
8eps=0.001;
9a_result=zeros(Iterations,N);
10b_result=zeros(Iterations,1);
11ret = 0;
12Y = 0;
13
14X=usps_read_partial(d16trn_1, d16trn_2,1,1,N/Iterations, Iterations);
15
16for iter=1:Iterations
17 Y=usps_read_partial(d16trn_1,d16trn_2,iter,0,N/Iterations, Iterations);
18 if iter==1
19 fWriteMatrix(Y, './');
20 end
21
22 a=zeros(N,1);
23 b=0;
24 e=zeros(N,1);
25 ExamineAll=1;
26 cnt=0;
27 NumChanged=0;
28 while (NumChanged>0 || ExamineAll == 1)
29 cnt=cnt+1;
30 NumChanged=0;
31 if ExamineAll==1
32 for i=1:N
33 [a,b,e,ret] = examineExample(i, a, b, C, e, X, Y, tolerance, N, eps, dim);
34 NumChanged=NumChanged+ret;
35 end
36 else
37 for i=1:N
38 if a(i,1) > 0 && a(i,1) < C
39 [a,b,e,ret] = examineExample(i, a, b, C, e, X, Y, tolerance, N, eps, dim);
40 NumChanged=NumChanged+ret;
41 end
42 end
43 end
44 if ExamineAll==1
45 ExamineAll=0;
46 elseif NumChanged==0
47 ExamineAll=1;
48 end
49 end
50
51 for r = 1:N
52 a_result(iter,r) = a(r,1);
53 end
54
55% a_result=transpose(a); %KVS: Problem using transpose function here. So wrote the code above
56 b_result(iter,1)=b;
57end
58