-
Notifications
You must be signed in to change notification settings - Fork 0
/
proxgrad.m
executable file
·58 lines (32 loc) · 940 Bytes
/
proxgrad.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
function [W] = proxgrad(X,Y,MAX_ITR, lambda,gamma,Bind,epsilon)
% Stepsize selection
if nargin < 7
error('7 input arguments needed');
end
m= size(X,1);
Task_Number=size(Y,2);
% Compute task specific featues:
Feature_Sets=Task_Features(Y, X, Bind);
% Compute step size
S=Compute_StepSize(Feature_Sets,Task_Number);
for num_iter = 1:MAX_ITR
if num_iter==1
W = zeros(size(X,2),size(Y,2));
W_pre = W;
end
W = Compute_gradient(Feature_Sets,Y,W,Task_Number,m);
% do proximal opertor:
gradient = proximal(W,lambda,gamma,Bind);
% Update the gradient:
W = W_pre - times(S , gradient) ;
W= W + (num_iter/(num_iter + 3)) * ( W - W_pre);
W_pre = W;
% if mod(num_iter,500)==1
Conv_Criteria = norm(gradient(:));
if Conv_Criteria < epsilon
break;
end
%end
%disp(num_iter);
end
end