-
Notifications
You must be signed in to change notification settings - Fork 25
/
loadssvmdata.m
86 lines (85 loc) · 2.73 KB
/
loadssvmdata.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
function [patterns, labels] = loadssvmdata(path, postfix, cnnflist, cnnprob, ...
dbn33flist, dbn33prob, dbn55flist, dbn55prob, gmmflist, gmmprob, priorprob)
%LOADSSVMDATA Summary of this function goes here
% Detailed explanation goes here
if sum(cnnprob(:)<0) > 0 || sum(dbn33prob(:)<0) > 0 || sum(dbn55prob(:)<0) > 0 ...
|| sum(gmmprob(:)<0)>0 || sum(priorprob(:)<0) > 0
display(path);
end
patterns = {} ;
labels = {} ;
filedir = dir([path '*' postfix]);
if length(filedir) ~= 58
display(path);
end
for i=1:length(filedir)
fname = filedir(i).name;
data = load([path fname]);
data = data.im;
cnnindex = findstr(cnnflist, fname);
dbn33index = findstr(dbn33flist, fname);
dbn55index = findstr(dbn55flist, fname);
gmmindex = findstr(gmmflist, fname);
cnndata0 = -log(1-cnnprob(cnnindex, :, :)+1e-6);
cnndata0 = squeeze(cnndata0);
cnndata = -log(cnnprob(cnnindex, :, :)+1e-6);
cnndata = squeeze(cnndata);
dbn33data0 = -log(1-dbn33prob(dbn33index, :, :)+1e-6);
dbn33data0 = squeeze(dbn33data0);
dbn33data = -log(dbn33prob(dbn33index, :, :)+1e-6);
dbn33data = squeeze(dbn33data);
dbn55data0 = -log(1-dbn55prob(dbn55index, :, :)+1e-6);
dbn55data0 = squeeze(dbn55data0);
dbn55data = -log(dbn55prob(dbn55index, :, :)+1e-6);
dbn55data = squeeze(dbn55data);
gmmdata0 = -log(1-gmmprob(gmmindex, :, :)+1e-6);
gmmdata0 = squeeze(gmmdata0);
gmmdata = -log(gmmprob(gmmindex, :, :)+1e-6);
gmmdata = squeeze(gmmdata);
priordata0 = -log(1-priorprob+1e-6);
priordata = -log(priorprob+1e-6);
alldata = ones(40, 40, 7, 2);
alldata(:,:,1,1) = data;
%alldata(:,:,1,2) = data;
alldata(:,:,2,1) = ones(40,40);
alldata(:,:,3,1) = cnndata;
alldata(:,:,3,2) = cnndata0;
alldata(:,:,4,1) = dbn33data;
alldata(:,:,4,2) = dbn33data0;
alldata(:,:,5,1) = dbn55data;
alldata(:,:,5,2) = dbn55data0;
alldata(:,:,6,1) = gmmdata;
alldata(:,:,6,2) = gmmdata0;
alldata(:,:,7,1) = priordata;
alldata(:,:,7,2) = priordata0;
%patterns{i} = alldata;
labelarr = load([path fname(1:end-length(postfix)+1) 'massgt.mat']); % 40 * 40 * 1
labelarr = labelarr.im;
%labels{i} = zeros(40, 40, 2);
%labels{i}(:,:,1) = 1 - labelarr;
%labelarr(labelarr==0) = -1;
x = zeros(40*40, 7);
y = zeros(40*40,1);
for j = 1 : 40
for k = 1 : 40
y((j-1)*40+k) = labelarr(j,k);
% x((j-1)*40+k, :) = alldata(j,k, :);
end
end
%if sum(y==0) > 1
% display(path);
%end
patterns{i} = alldata;
labels{i} = y; %labelarr; %[-y y];
%size(labels{i})
end
end
function [row] = findstr(strarr, str)
row = 0;
for i = 1 : size(strarr,1)
if strcmp(strarr(i,:), str) == 1
row = i;
break;
end
end
end