#include #include #define MXUNIT 16 #define MXTRSMPL 1000 float eta, alpha, beta, ts, sys_err, maxe, wt[MXUNIT][MXUNIT], /* weight matrix */ dwt[MXUNIT][MXUNIT], /* delta weight */ yy[MXUNIT], /* node outputs */ oldppp[MXUNIT][MXUNIT][MXUNIT], /* dynamics at time t */ newppp[MXUNIT][MXUNIT][MXUNIT], /* dynamics at time t+1 */ zz[MXUNIT], /* node output + ext. input */ fs[MXUNIT], /* activation */ inp[MXTRSMPL][MXUNIT], /* training inputs */ outpt[MXTRSMPL][MXUNIT], /* computed outputs */ target[MXTRSMPL][MXUNIT], /* target outputs */ ee[MXUNIT], /* error */ err[MXTRSMPL]; int nsamples, /* number of training samples */ nunits, /* number of units */ ninput=0, /* number of inputs */ noutput=0, /* number of outputs */ nhidden, /* number of hidden nodes */ mxniter, /* counter for no. itertn */ tot_iter, outindx[MXUNIT], /* unit numbers for output */ nrow,ncol, /* number of rows and columns */ ntsdata, ntsunits, nunf; char net_file[20]; /* name of network data file */ FILE *fp1, /* training sample file */ *fp2, /* net data file to write */ *fp3, /* net data file to read */ *fp4, /* test data file */ *fp5, /* test output file */ *fp6; /* training output file */ void set_up_train() { int i,j; char tr_data_file[20], tofile[20]; printf("\nLearning rate eta?: "); scanf("%f",&eta); printf("\nNumber of iterations in each free running?: "); scanf("%d",&nunf); printf("\nMax total error?: "); scanf("%f",&maxe); printf("\nMax number of iterations?: "); scanf("%d",&mxniter); printf("\nNumber of Units?: "); scanf("%d",&nunits); printf("\nNumber of Iutput Units?: "); scanf("%d",&ninput); printf("\nNumber of Output Units?: "); scanf("%d",&noutput); printf("\nEnter Unit Numbers for Output Units:"); for (i=0; i maxe)); tot_iter=i; } /* end of WILLIAMS */ void wrap_up_train() { int i,j; char key; /* save weights in a file for later use */ if (( fp2 = fopen(net_file,"w")) == NULL) { perror("\n Cannot open network data file "); exit(0); } fprintf(fp2,"%d %d %d %d\n",nunits,ninput,noutput,nhidden); for (i=0; i