0% found this document useful (0 votes)
24 views2 pages

Neuron A

f

Uploaded by

Dana
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views2 pages

Neuron A

f

Uploaded by

Dana
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

t = [1 4 3 4 5];

x = [2; 3; 5; 1; 2];
w = 1;

for l = 1:9
a = x .* w ;
y = sigmoid(a) ;
e = t - y ;
g = -x' .* e ;
w = w - 0.01 * ( g + 0.01 * w ) ;
end

g = gradM ( w ) ;
M = findM ( w ) ;
for l = 1:L
p = randn ( size(w) ) ;
H = p' * p / 2 + M ;
p = p - epsilon * g / 2 ;
wnew = w + epsilon * p ;
gnew = gradM ( wnew ) ;
p = p - epsilon * gnew / 2 ;
Mnew = findM ( wnew ) ;
Hnew = p' * p / 2 + Mnew ;
dH = Hnew - H ;
if ( dH < 0 )
accept = 1 ;
elseif ( rand() < exp(-dH) )
accept = 1 ;
else
accept = 0 ;
end
if ( accept )
g = gnew ; w = wnew ; M = Mnew ;
end
end

Function Sinusoidal

function f = sigmoid ( v )

f = 1 / ( 1 + exp ( - v ) ) ;

end

//

function M = findM ( w )
G = - (t' * log(y) + (1-t') * log( 1-y )) ;
EW = w' * w / 2 ;
M = G + alpha * EW ;
end
function gM = gradM ( w )
a = x * w ;
y = sigmoid(a) ;
e = t - y ;
g = - x' * e ;
gM = alpha * w + g ;
end

You might also like