-
Notifications
You must be signed in to change notification settings - Fork 45
/
demo_src_esrc_comparison.m
78 lines (61 loc) · 2.06 KB
/
demo_src_esrc_comparison.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
close all;
clear;
clc;
%% load dataset
%load('../dataset/ORL_Face_img.mat');
%load('../dataset/Brodatz_texture_img_small_set.mat');
load('../dataset/AR_Face_img_27x20.mat');
%load('../dataset/AR_Face_img_60x43.mat');
%load('../dataset/USPS.mat');
%load('../dataset/MNIST.mat');
%load('../dataset/COIL20.mat');
%%load('../dataset/COIL100.mat');
% set paramters
eigenface_flag = false;
%% reduce dataset for a quick test if necessary
max_class_num = 50;
max_samples = 5;
[TrainSet, TestSet, train_num, test_num, class_num] = reduce_dataset(TrainSet, TestSet, max_class_num, max_samples);
%% normalize dataset
[TrainSet.X, TrainSet.y] = data_normalization(TrainSet.X, TrainSet.y, 'std');
[TestSet.X, TestSet.y] = data_normalization(TestSet.X, TestSet.y, 'std');
%
eigenface_dim = max_class_num*max_samples;
if eigenface_dim > train_num
eigenface_dim = train_num;
end
%% SRC
clear options;
lambda = 0.001;
options.verbose = true;
options.eigenface = eigenface_flag;
options.eigenface_dim = eigenface_dim;
accuracy_src = src(TrainSet, TestSet, train_num, test_num, class_num, lambda, options);
fprintf('# SRC Accuracy = %5.5f\n', accuracy_src);
%% ESRC
clear options;
lambda = 0.001;
options.verbose = true;
options.eigenface = eigenface_flag;
options.eigenface_dim = eigenface_dim;
accuracy_esrc = esrc(TrainSet, TestSet, train_num, test_num, class_num, lambda, options);
fprintf('# ESRC Accuracy = %5.5f\n', accuracy_esrc);
%% SDR_SLR
clear options;
v = 1*sqrt(size(TrainSet.X,1))^-1;
options.slr_v = v;
options.slr_lambda = 1;
options.slr_tau = 0.01;
options.slr_delta = 1.2 * v;
options.slr_eta = 1 * v;
% parameters setting for sdr
options.sdr_beta = 10;
options.sdr_gamma = 10;
options.verbose = true;
accuracy_sdr_slr = sdr_slr(TrainSet, TestSet, train_num, test_num, class_num, options);
fprintf('# SDR-SLR Accuracy = %5.5f\n', accuracy_sdr_slr);
%% display accuracy
fprintf('\n\n## Summary of results\n\n')
fprintf('# SRC: Accuracy = %5.5f\n', accuracy_src);
fprintf('# ESRC: Accuracy = %5.5f\n', accuracy_esrc);
fprintf('# SDR-SLR Accuracy = %5.5f\n', accuracy_sdr_slr);