-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathLoadOfficePlusCaltechData.m
More file actions
33 lines (31 loc) · 1017 Bytes
/
LoadOfficePlusCaltechData.m
File metadata and controls
33 lines (31 loc) · 1017 Bytes
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
function [Data, Labels] = LoadOfficePlusCaltechData(foldername, norm_type)
fname = '%s_SURF_L10.mat';
domain_names = {'amazon', 'webcam', 'dslr', 'Caltech10'};
Data = cell(numel(domain_names));
Labels = cell(numel(domain_names));
for d = 1:numel(domain_names)
fullfilename = fullfile(foldername, sprintf(fname, domain_names{d}));
load(fullfilename);
fts = NormData(fts, norm_type);
Data{d} = fts;
Labels{d} = labels';
end
end
function fts = NormData(fts, norm_type)
switch norm_type
case 'l1_zscore'
fts = fts ./ repmat(sum(abs(fts),2),1,size(fts,2));
fts = zscore(fts,1);
case 'l2_zscore'
fts = fts ./ repmat(sqrt(sum(fts.^2,2)),1,size(fts,2));
fts = zscore(fts,1);
case 'l1'
fts = fts ./ repmat(sum(abs(fts),2),1,size(fts,2));
case 'l2'
fts = fts ./ repmat(sqrt(sum(fts.^2,2)),1,size(fts,2));
case 'none'
return;
otherwise
error('norm');
end
end