From: Rethabile on
hi,
i'm trying to implement backpropagation network to learn certain functions.
but my error stay above something like 200. where may i be doing wrong?

here is the code. 2 inputs, 3 hidden nodes and 2 output nodes.

echo on
clc

clear all
x = [0 1 2 3 4
-2 -1 0 1 2];
d=[-1 3.736 3.271 3.100 9.037
15.000 13.000 15.000 21.000 31.000];

% x = [0 1 2
% -2 1 2];
% d=[-1 5 11.27
% 0 1 0];
%weights connecting inputs to the hidden node
iw = zeros(3,2);
%weights connecting hidden nodes with the output nodes
lw= zeros(2,3);

%learning rate
mu = 0.25;

%test parttens
max_tests = 5;

echo off;pause
mse = inf;
a = 0;
tic
while(mse > 0.26)
sum = 0;
a = a+1;
for n=1:max_tests,

a_in=iw*x(:,n);
a=[1/(1+exp(-a_in(1))) 1/(1+exp(-a_in(2))) 1/(1+exp(-a_in(3)))];

y_in = lw*a';

y = [1/(1+exp(-y_in(1))) 1/(1+exp(-y_in(2)))];


e = d(:,n)'-y

thetaout=[e(1)*y(1)*(1-y(2));
e(2)*y(2)*(1-y(2))];

thetaL1 = a(1)*(1-a(1))*lw(:,1)'*thetaout;
thetaL2 = a(2)*(1-a(2))*lw(:,2)'*thetaout;
thetaL3 = a(3)*(1-a(3))*lw(:,3)'*thetaout;

lw(1,:)=lw(1,:)+mu*e(1)*a;
lw(2,:)=lw(2,:)+mu*e(2)*a;
iw(1,:)=iw(1,:)+mu*thetaL1*x(:,n)';
iw(2,:)=iw(2,:)+mu*thetaL2*x(:,n)';
iw(3,:)=iw(3,:)+mu*thetaL3*x(:,n)';

sum= sum+(e(1)*e(1)+e(2)*e(2))/2;
['iteration #: ' int2str(a) ':']


% pause
end
sum
mse=sum/max_tests
end
toc
iw
lw

From: Rethabile on
any help?