Diff of /MLFre/DPC/SLEP/sll_opts.m [000000] .. [d8e26d]

Switch to unified view

a b/MLFre/DPC/SLEP/sll_opts.m
1
function opts = sll_opts(opts)
2
3
% Options for Sparse Learning Library
4
%
5
% Notice:
6
% If one or several (even all) fields are empty, sll_opts shall assign the
7
% default settings.
8
%
9
% If some fields of opts have been defined, sll_opts shall check the fields
10
% for possible errors.
11
%
12
%
13
% Table of Options.  * * indicates default value.
14
%
15
%% FIELD            DESCRIPTION
16
%% Starting point
17
%
18
% .x0               Starting point of x. 
19
%                   Initialized according to .init.
20
%
21
% .c0               Starting point for the intercept c (for Logistic Loss)
22
%                   Initialized according to .init.
23
%
24
% .init             .init specifies how to initialize x.  
25
%                       * 0 => .x0 is set by the function initFactor *
26
%                         1 => .x0 and .c0 are defined
27
%                         2 => .x0= zeros(n,1), .c0=0
28
%
29
%% Termination
30
%
31
% .maxIter          Maximum number of iterations.
32
%                       *1e4*
33
%
34
% .tol              Tolerance parameter.
35
%                       *1e-4*
36
%
37
% .tFlag            Flag for termination.
38
%                       * 0 => abs( funVal(i)- funVal(i-1) ) <= .tol *
39
%                         1 => abs( funVal(i)- funVal(i-1) ) 
40
%                              <= .tol max( funVal(i-1), 1)
41
%                         2 => funVal(i) <= .tol
42
%                         3 => norm( x_i - x_{i-1}, 2) <= .tol
43
%                         4 => norm( x_i - x_{i-1}, 2) <= 
44
%                              <= .tol max( norm( x_{i-1}, 2), 1 )
45
%                         5 => Run the code for .maxIter iterations
46
%
47
%% Normalization
48
%
49
% .nFlag            Flag for implicit normalization of A.
50
%                       * 0 => Do not normalize A *
51
%                         1 => A=(A-repmat(mu, m, 1))*diag(nu)^{-1}
52
%                         2 => A=diag(nu)^{-1}*(A-repmat(mu,m,1)
53
%
54
% .mu               Row vector to be substracted from each sample.
55
%                           (.mu is used when .nFlag=1 or 2)
56
%                       If .mu is not specified, then
57
%                            * .mu=mean(A,1) *
58
%
59
% .nu               Weight (column) vector for normalization
60
%                           (.mu is used when .nFlag=1 or 2)
61
%                       If .nu is not specified, then
62
%                       * .nFlag=1 => .nu=(sum(A.^2, 1)'/m.^{0.5} *
63
%                       * .nFlag=2 => .nu=(sum(A.^2, 2)/n.^{0.5} *
64
%
65
%% Regularization
66
%
67
% .rFlag            Flag for regularization
68
%                           (.rFlag is used for the functions with "R")
69
%                        * 0 => lambda is the regularization parameter *
70
%                          1 => lambda = lambda * lambda_{max}
71
%                               where lambda_{max} is the maximum lambda
72
%                               that yields the zero solution
73
% .rsL2              Regularization parameter value of the squared L2 norm
74
%                           (.rsL2 is used only for l1 regularization)
75
%                        *.rsL2=0*
76
%                    If .rFlag=0, .rsL2 is used without scaling
77
%                       .rFlag=1, .rsL2=.rsL2 * lambda_{max}
78
%
79
%% Method & Line Search
80
% .lFlag
81
%
82
%% Grooup & Others
83
%
84
% .ind              Indices for k groups (a k+1 row vector)
85
%                   For group lasso only
86
%                   Indices for the i-th group are (ind(i)+1):ind(i+1)
87
%
88
% .q                Value of q in L1/Lq regularization
89
%                      *.q=2*
90
%
91
% .sWeight          The sample (positive and negative) weight
92
%                   For the Logistic Loss only
93
%                   Positive sample: .sWeight(1)
94
%                   Negative sample: sWeight(2)
95
%                   *1/m for both positive and negative samples*
96
%
97
% .gWeight          The weight for different groups
98
%                      *.gWeight=1*
99
%
100
% .fName            The name of the function
101
%
102
%% Copyright (C) 2009-2010 Jun Liu, and Jieping Ye
103
%
104
% You are suggested to first read the Manual.
105
%
106
% For any problem, please contact with Jun Liu via j.liu@asu.edu
107
%
108
% Last modified 7 August 2009.
109
110
%% Starting point
111
112
if isfield(opts,'init')
113
    if (opts.init~=0) && (opts.init~=1) && (opts.init~=2)
114
        opts.init=0; % if .init is not 0, 1, or 2, then use the default 0
115
    end
116
    
117
    if ~isfield(opts,'x0') && (opts.init==1)
118
        opts.init=0; % if .x0 is not defined and .init=1, set .init=0
119
    end
120
else
121
    opts.init = 0; 
122
                     % if .init is not specified, use "0"
123
end
124
125
%% Termination
126
127
if isfield(opts,'maxIter')
128
    if (opts.maxIter<1)
129
        opts.maxIter=10000;
130
    end
131
else
132
    opts.maxIter=10000;
133
end
134
135
if ~isfield(opts,'tol')
136
    opts.tol=1e-3;
137
end
138
139
if isfield(opts,'tFlag')
140
    if opts.tFlag<0
141
        opts.tFlag=0;
142
    elseif opts.tFlag>5
143
        opts.tFlag=5;
144
    else
145
        opts.tFlag=floor(opts.tFlag);
146
    end
147
else
148
    opts.tFlag=0;
149
end
150
151
%% Normalization
152
153
if isfield(opts,'nFlag')
154
    if (opts.nFlag~=1) && (opts.nFlag~=2)
155
        opts.nFlag=0;
156
    end
157
else
158
    opts.nFlag=0;
159
end
160
161
%% Regularization
162
163
if isfield(opts,'rFlag')
164
    if (opts.rFlag~=1)
165
        opts.rFlag=0;
166
    end
167
else
168
    opts.rFlag=0;
169
end
170
%% Method (Line Search)
171
172
if isfield(opts,'lFlag')
173
    if (opts.lFlag~=1)
174
        opts.lFlag=0;
175
    end
176
else
177
    opts.lFlag=0;
178
end
179
180
if isfield(opts,'mFlag')
181
    if (opts.mFlag~=1)
182
        opts.mFlag=0;
183
    end
184
else
185
    opts.mFlag=0;
186
end
187