COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### Backpropagation algorithm for weather prediction

• Email
• Follow

```Hi, I am working on a project of weather forecasting.I am using the data from site http://www.wunderground.com/history/airport/VABB/2005/3/27/CustomHistory.html?dayend=27&monthend=3&yearend=2006&req_city=NA&req_state=NA&req_statename=NA

i have converted that data to excel sheets and using only average values of temperature,dew point,humidity and pressure.i have written following code using backpropagation algorithm.The algorithm is not converging in the written code.Can anyone help in thios case?

%normalizing the inputs...
[nortemp]=normalize(temp);
[nordew]=normalize(dewpt);
[norhum]=normalize(humidity);
[norpre]=normalize(pressure);

%initializing weights of the links between input layer to hidden layer
%w1 stands for links coming out from first input layer...similar in case of
%w2,w3,w4..
w1=[0.1 0.1 0.1 ];
w2=[0.1 0.1 0.1 ];
w3=[0.1 0.1 0.1 ];
w4=[0.1 0.1 0.1 ];
%initializing the weights between the links hidden to output..
%ow1 stands for weights between first hidden node to all output nodes..
ow1=[0.1 0.1 0.1 0.1];
ow2=[0.1 0.1 0.1 0.1];
ow3=[0.1 0.1 0.1 0.1];

%E=1;

%while (E>)
E=0;
%its not converging.. hence for testing purpose using for loop and not the
%condition E>Emax
for m=1:25
E=0;

for i=1:365
%forward pass....

%using tangent function and -1 as bias
%calculating outpus of hidden nodes
for j=1:3
h(j)=1.7159*tanh(0.6667*(w1(j)*nortemp(i)+w2(j)*nordew(i)+w3(j)*norhum(i)+w4(j)*norpre(i)-1));
end

%calculating outpus of output nodes.. bias -1
for j=1:4
o(j)=1.7159*tanh(0.6667*(ow1(j)*h(1)+ow2(j)*h(2)+ow3(j)*h(3)-1));
end

%desired output is next day's weather
e(1)=nortemp(i+1)-o(1);
e(2)=nordew(i+1)-o(2);
e(3)=norhum(i+1)-o(3);
e(4)=norpre(i+1)-o(4);

%backward pass

for j=1:4
end

%calculating the values of the new weights in links between hidden and output layer

%owts is a function that calculates weights...
for j=1:4
end

for j=1:3
end

%calculating the values of the new weights in links between input
%layer and hidden layer..
%htws is a function that calculates weights...

%calculating error for this cycle
E=E+((e(1)^2)+(e(2)^2)+(e(3)^2)+(e(4)^2))/8;

end
disp('E=');disp(E);
disp('o=');disp(o);
end

------------------------------------------------------------------------------------------------------------------
% normalization

function [m]=normalize(t)
a=t(1);b=t(1);

%calculating the highest and lowest values...
for i=1:1828
if (t(i)<a)
a=t(i);
end

if (t(i)>b)
b=t(i);
end
end

%normalizing the data..
for i=1:1828
m(i)=-1+2*(t(i)-a)/(b-a);
end

---------------------------------------------------------------------------------------------------------------------

function [a,b,c]=owts(h,g,p,q,r)
a=p+0.1*g*h(1);
b=q+0.1*g*h(2);
c=r+0.1*g*h(3);
end

-------------------------------------------------------------------------------------------------------------------

function [a,b,c]=hwts(h,g,p,q,r)
a=p+0.1*g(1)*h;
b=q+0.1*g(2)*h;
c=r+0.1*g(3)*h;
end

-------------------------------------------------------------------------------------------------------------------
```
 0

See related articles to this posting

```I have used 4-3-4 architecture in this case..
```
 1