I am working on a basic machine learning algorithm.
here are some of my code
this code works, but i want to run this code with different alpha value (learning rate)
for example, i want to know the different result according to the different alpha values (alpha = [0.1:0.1:1])
i know that i can manually change the alpha value each time to get the each results
but i want to know if there is any other method so that i dont have to change alpha value each time.
trn = 10000; % training pattern 갯수
ten = 10000; % testing pattern 갯수
echo = 10; % 학습반복 횟수
rate = 1;
w = (rand(784,10)-0.5)*2; % -1 ~ 1 사이의 weight값 random하게 생성
s = zeros(1,10); % Integration 부분
o = zeros(1,10); % Activation 부분
alpha = 0.1; % learning rate
count = 0;
%-------------------------------------------------------Learing--------------------------------------------------
for z=1:echo
for j=1:trn
i=image(j,:); % j-th pattern
l=label(j,:); % j-th label
s=i*w; % input*weight 의 합
i_t = i.'; % transposd of i
o=s;
y = 1./(1+exp(-1.*o)); % Sigmoid Activation function 적용
mean_square = (y - l).^2; % mean_square 적용
del_y = y.*(1-y);
del_mean = 2.*(y-l);
del_w = i_t.* del_y .* del_mean;
w=w-(alpha.*del_w);
end
end
%---------------------------------------------------Testing-----------------------------------------------
for k=1:ten
i=image1(k,:);
l=label1(k,:);
s=i*w; % input*weight 의 합
o=s;
y = 1./(1+exp(-1.*o)); % Sigmoid Activation function 적용
h=max(y);
y(y < h) = 0;
y(y == h) = 1;
if y == l
count=count+1;
end
end