Written by Don grub, this book teaches students how to write Tibetan from the very beginning. It is divided into two parts. Part One includes the consonants, alphabet and vowels. Part Two illustrat...
} else { if (y[i] == 0) { continue; } else { threshold = threshold - w[m]; w[m] = (w[m] + learn_rate); for (int j = 0; j < m; j++) { if (x[i][j] == 1) { w[j] = (w[j] + learn_rate); } } i=-1; } } } cout<<"\n"; for(j=0;j<=m;j++) { cout<<"\tw"<
cin>>in[j]; } calc_out=0; for(j=0;j= threshold) //Checking for threshold value { cout<<"Output for this Test case is 1\n"; } else { cout<<"Output for this Test case is 0\n"; } cout<<"Press 1 for test again else 0 : "; cin>>i; }while(i==1); return(0); } OUTPUT hemant@hemant-laptop:~/h$ g++ perceptron1.cc hemant@hemant-laptop:~/h$ ./a.out Enter no. of bits for input : 3 Enter no. of training sets you want to learn : 5 Enter training set 1 1 1 Enter Desired output : 1 Enter training set 0 1 1 Enter Desired output : 0 Enter training set
1 0 1 Enter Desired output : 0 Enter training set 1 1 0 Enter Desired output : 0 Enter training set 1 0 0 Enter Desired output : 0 w1 0.3 w2 0.3 Error0.08 Error0.005 Error0.005 Error0.02 Error0.005 Error0.125 Error0.00500001 Error0.02 Error0.02 Error0.00500001 Error0.125 Error0.00500001 Error0.02 Error0.02 Error0.02 Error0.125 w1 0.3 w2 Threshold 0.8 Enter Test set 1 1 1 Output for this Test case is 1 Press 1 for test again else 0 : 1 Enter Test set 0
w3
0.3
w4
0.3
0.3
w3
0.3
w4
1.78814e-08
1 0 Output for this Test case is 0 Press 1 for test again else 0 : 1 Enter Test set 0 0 1 Output for this Test case is 0 Press 1 for test again else 0 : 0
B1: Write a program for back propagation algorithm.
#include #include #include #define eta 2.0 using namespace std; int main() { int c,i,j,hidden_unit,no_bits,l,k,p,no_sample,b; float input[10][10],t,target_out[10],weight_hidden[10] [10],weight_out[10],change_weight_hidden[10][10],change_weight_out[10]; float actual_out_hidden[10],net_hidden[10],net_out,actual_out_out,net,in[10]; double error; clock_t start,end; cout<<"\nEnter the no of neuron in hidden layer layer: "; cin>>hidden_unit; cout<<"\nEnter the no of bits of input: "; cin>>no_bits; cout<<"\nEnter the no of sample: "; cin>>no_sample; //LOOP FOR ENTERING INPUT SAMPLE FROM THE USER for (i=0;i
cin>>input[i][j]; } cout<<"Enter the corresponding output: "; cin>>target_out[i]; } input[i][no_bits]=1;
//change in weight between the hidden layer and output layer for (i=0;i
} } }//end of sample loop cout<<"\nGlobal Error="<
} //end of while loop
end = clock(); cout<<"Learning Time"<<(end-start)/CLOCKS_PER_SEC<<"(in second)"; //FINAL WEIGHTS cout<<"\n################# MODIFIED WEIGHT FOR HIDDEN LAYER ###################\n"; for (j=0;j
cout<<"\nWeight ("<
} } cout<<"\n############## MODIFIED WEIGHT FOR OUTPUT LAYER ################\n"; for (i=0;i
cout<<"\nWeight ("<
}
/*USED FOR CALCULATING OUTPUT FOR THE PARTICULAR SAMPLE(TESTING)*/ cout<<"\n########################### TESTING PHASE ################################\n"; c=0; while(c==0) { cout<<"\nEnter the input for testing "; for(i=0;i>in[i]; } in[no_bits]=1;