Sunteți pe pagina 1din 11

Department of Computing

COURSE: Artificial Intelligence Techniques MARKS:


COURSE CODE: BCS2313
SEMESTER:1
TOPIC : Neural Network
TYPE OF PROJECT: Group
PROJECTNO: 1
TIME /DEADLINE: 31/December/2017
STUDENT ID/NAME:
Fatma Ali Al-Mandhari (15317) SIGNATURE/DATE:

Areej Mohammed Al-Mammari(14201) SIGNATURE/DATE:

Sara Abdullah Said Al-Hosni(14147) SIGNATURE/DATE:

Nawaf Mubark AL-Gailani(15275) SIGNATURE/DATE:

Haithm AL-Rayami (15356) SIGNATURE/DATE:

SECTION: 1
FEEDBACK(If Any):

LECTURER NAME: Ferddie Quiroz Canlas SIGNATURE:


Project No 1

CONTENTS
Screenshot of output............................................................................................................................. 3
Input ..................................................................................................................................................... 5
Output and error ................................................................................................................................... 7
Sigmoid activation function and gradient function .............................................................................. 8
Forward and backward propagation process ...................................................................................... 10

2|Page BCS2313
Project No 1

SCREENSHOT OF OUTPUT

Sum of hidden layer

Sigmoid of hidden layer

Output

Sigmoid of Output

Error

Back Propagation
(Compute for gradient)

Adjusting wright

Figure 1: Output

3|Page BCS2313
Project No 1

Adjusting wright

Sum of hidden layer after


adjusting wright

Sigmoid of hidden layer


after adjusting wright

New output

Sigmoid of new output

New Error

Figure 2: Output

4|Page BCS2313
Project No 1

INPUT
mob=0.0001;
tp=0.25;
n=2;
target=0;
// weights
w1h1=0.8;
w1h2=0.4;
w1h3=0.3;
w2h1=0.2;
w2h2=0.9;
w2h3=0.5;
// the i value
i1=1;
i2=1;
//to out put weights
wh1o=0.3;
wh2o=0.5;
wh3o=0.9;

Weights
First weights:

w1h1=0.8;

w1h2=0.4;

w1h3=0.3;

w2h1=0.2;

w2h2=0.9;

w2h3=0.5;

//to out put weights

wh1o=0.3;

5|Page BCS2313
Project No 1

wh2o=0.5;

wh3o=0.9;

New weights:

nw1h1=w1h1+mob*w1h1*(n-1)+tp*g1*shh1;

printf("the new weight of w1h1 is %f \n",nw1h1);

printf("\n");

nw1h2=w1h2+mob*w1h2*(n-1)+tp*g2*shh2;

printf("the new weight for w1h2 is %f \n",nw1h2);

printf("\n");

nw1h3=w1h3+mob*w1h3*(n-1)+tp*g3*shh3;

printf("the new weight for w1h3 is %f \n",nw1h3);

printf("\n");

nw2h1=w2h1+mob*w2h1*(n-1)+tp*g1*shh1;

printf("the new weight for w2h1 is %f \n",nw2h1);

printf("\n");

nw2h2=w2h2+mob*w2h2*(n-1)+tp*g2*shh2;

printf("the new weight for w2h2 is %f \n",nw2h2);

printf("\n");

nw2h3=w2h3+mob*w2h3*(n-1)+tp*g3*shh3;

printf("the new weight for w2h3 is %f \n",nw2h3);

printf("\n");

nwh1o=wh1o+mob*wh1o*(n-1)+tp*go*soutput;

printf("the new weight for w1ho is %f \n",nwh1o);

printf("\n");

nwh2o=wh2o+mob*wh2o*(n-1)+tp*go*soutput;

printf(" the new weight for wh2o is %f\n ",nwh2o);

6|Page BCS2313
Project No 1

printf("\n");

nwh3o=wh3o+mob*wh3o*(n-1)+tp*go*soutput;

printf(" the new weight for wh3o is %f\n",nwh3o);

printf("\n");

OUTPUT AND ERROR


First output:

output=(shh1*wh1o)+(shh2*wh2o)+(shh3*wh3o);

printf("the output is %f \n",output);

printf("\n");

Find the error after get sigmoid of output

soutput=1/(1+(exp(output*-1)));

printf("the sgmoid of the out put is %f \n",soutput);

printf("\n");

erorr= target-soutput;

printf("the error is %f \n",erorr);

printf("\n");

New output:

noutput=(nshh1*nwh1o)+(nshh2*nwh2o)+(nshh3*nwh3o);

printf("the new output is %f \n",noutput);

printf("\n");

New error:

nsoutput=1/(1+(exp(noutput*-1)));

printf("the new sgmoid of the out put is %f \n",nsoutput);

printf("\n");

7|Page BCS2313
Project No 1

nerorr= target-nsoutput;

printf("the new error is %f \n",nerorr);

SIGMOID ACTIVATION FUNCTION AND GRADIENT FUNCTION


Sigmoid of hidden:

shh1=1/(1+(exp(hh1*-1)));

printf("the sigmoid of h1 is %f \n",shh1);

printf("\n");

shh2=1/(1+(exp(hh2*-1)));

printf("the sigmoid of h2 is %f \n",shh2);

printf("\n");

shh3=1/(1+(exp(hh3*-1)));

printf("the sgmoid of h3 is %f \n",shh3);

printf("\n");

Sigmoid of Output:

soutput=1/(1+(exp(output*-1)));

printf("the sgmoid of the out put is %f \n",soutput);

printf("\n");

Sigmoid of hidden after get new weights:

nshh1=1/(1+(exp(nhh1*-1)));

printf("the new sigmoid of new h1 is %f \n",nshh1);

printf("\n");

nshh2=1/(1+(exp(nhh2*-1)));

printf("the new sigmoid of new h2 is %f \n",nshh2);

printf("\n");

8|Page BCS2313
Project No 1

nshh3=1/(1+(exp(nhh3*-1)));

printf("the new sgmoid of new h3 is %f \n",nshh3);

printf("\n");

New sigmoid of output :

nsoutput=1/(1+(exp(noutput*-1)));

printf("the new sgmoid of the out put is %f \n",nsoutput);

printf("\n");

Gradient function :

printf("starting with backwards propogration ....... \n");

printf("\n");

go=soutput*(1-soutput)*erorr;

printf("the gradiant of the output is %f \n",go);

printf("\n");

g1=shh1*(1-shh1)*go*wh1o;

printf("the grediant of simoind H1 is %f \n",g1);

printf("\n");

g2=shh2*(1-shh2)*go*wh2o;

printf("the grediant of sigmoid H2 is %f \n",g2);

printf("\n");

g3=shh3*(1-shh3)*go*wh3o;

printf("the grediant of sigmoid H3 is %f \n",g3);

printf("\n");

9|Page BCS2313
Project No 1

FORWARD AND BACKWARD PROPAGATION PROCESS


Forward :

hh1=(i1*w1h1)+(i2*w2h1);

printf("the hidden of H1 is%f \n",hh1);

printf("\n");

hh2=(w1h2*i1)+(w2h2*i2);

printf("the hidden of H2 is %f \n",hh2);

printf("\n");

hh3=(i1*w1h3)+(i2*w2h3);

printf("the hidden of H3 is %f \n",hh3);

printf("\n");

shh1=1/(1+(exp(hh1*-1)));

printf("the sigmoid of h1 is %f \n",shh1);

printf("\n");

shh2=1/(1+(exp(hh2*-1)));

printf("the sigmoid of h2 is %f \n",shh2);

printf("\n");

shh3=1/(1+(exp(hh3*-1)));

printf("the sgmoid of h3 is %f \n",shh3);

printf("\n");

output=(shh1*wh1o)+(shh2*wh2o)+(shh3*wh3o);

printf("the output is %f \n",output);

printf("\n");

soutput=1/(1+(exp(output*-1)));

printf("the sgmoid of the out put is %f \n",soutput);

10 | P a g e
BCS2313
Project No 1

printf("\n");

erorr= target-soutput;

printf("the error is %f \n",erorr);

printf("\n");

printf("forward nueral network propegeration is completed \n");

printf("\n");

Backwards propagation

printf("starting with backwards propogration ....... \n");

printf("\n");

go=soutput*(1-soutput)*erorr;

printf("the gradiant of the output is %f \n",go);

printf("\n");

g1=shh1*(1-shh1)*go*wh1o;

printf("the grediant of simoind H1 is %f \n",g1);

printf("\n");

g2=shh2*(1-shh2)*go*wh2o;

printf("the grediant of sigmoid H2 is %f \n",g2);

printf("\n");

g3=shh3*(1-shh3)*go*wh3o;

printf("the grediant of sigmoid H3 is %f \n",g3);

printf("\n");

11 | P a g e
BCS2313

S-ar putea să vă placă și