From e46954901a16f1d49f3523be6bfd3eb60ee61dfa Mon Sep 17 00:00:00 2001 From: =?utf8?q?Christian=20W=C3=BCrdig?= Date: Fri, 31 Mar 2006 10:26:34 +0000 Subject: [PATCH] added additional files --- ir/be/test/harness.lst | 52 ++ ir/be/test/scanner.c | 1269 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 1321 insertions(+) create mode 100644 ir/be/test/harness.lst create mode 100644 ir/be/test/scanner.c diff --git a/ir/be/test/harness.lst b/ir/be/test/harness.lst new file mode 100644 index 000000000..a8a89602c --- /dev/null +++ b/ir/be/test/harness.lst @@ -0,0 +1,52 @@ + hmmm, not ready fill_text_buffer harness.c 31 + hmmm, not ready compare_buffer harness.c 10 + hmmm, not ready add_line harness.c 9 + hmmm, not ready main harness.c 8 + hmmm, not ready fill_text_buffer harness.c 31 + hmmm, not ready compare_buffer harness.c 10 + hmmm, not ready add_line harness.c 9 + hmmm, not ready main harness.c 8 + hmmm, not ready fill_text_buffer harness.c 31 + hmmm, not ready compare_buffer harness.c 10 + hmmm, not ready add_line harness.c 9 + hmmm, not ready main harness.c 8 + hmmm, not ready fill_text_buffer harness.c 31 + hmmm, not ready compare_buffer harness.c 10 + hmmm, not ready add_line harness.c 9 + hmmm, not ready main harness.c 8 + hmmm, not ready fill_text_buffer harness.c 31 + hmmm, not ready compare_buffer harness.c 10 + hmmm, not ready add_line harness.c 9 + hmmm, not ready main harness.c 8 + hmmm, not ready fill_text_buffer harness.c 31 + hmmm, not ready compare_buffer harness.c 10 + hmmm, not ready add_line harness.c 9 + hmmm, not ready main harness.c 8 + hmmm, not ready fill_text_buffer harness.c 31 + hmmm, not ready compare_buffer harness.c 10 + hmmm, not ready add_line harness.c 9 + hmmm, not ready main harness.c 8 + hmmm, not ready fill_text_buffer harness.c 31 + hmmm, not ready compare_buffer harness.c 10 + hmmm, not ready add_line harness.c 9 + hmmm, not ready main harness.c 8 + hmmm, not ready fill_text_buffer harness.c 31 + hmmm, not ready compare_buffer harness.c 10 + hmmm, not ready add_line harness.c 9 + hmmm, not ready main harness.c 8 + hmmm, not ready fill_text_buffer harness.c 31 + hmmm, not ready compare_buffer harness.c 10 + hmmm, not ready add_line harness.c 9 + hmmm, not ready main harness.c 8 + hmmm, not ready fill_text_buffer harness.c 31 + hmmm, not ready compare_buffer harness.c 10 + hmmm, not ready add_line harness.c 9 + hmmm, not ready main harness.c 8 + hmmm, not ready fill_text_buffer harness.c 31 + hmmm, not ready compare_buffer harness.c 10 + hmmm, not ready add_line harness.c 9 + hmmm, not ready main harness.c 8 + hmmm, not ready fill_text_buffer harness.c 31 + hmmm, not ready compare_buffer harness.c 10 + hmmm, not ready add_line harness.c 9 + hmmm, not ready main harness.c 8 diff --git a/ir/be/test/scanner.c b/ir/be/test/scanner.c new file mode 100644 index 000000000..6adcc5fae --- /dev/null +++ b/ir/be/test/scanner.c @@ -0,0 +1,1269 @@ +/*$Header$*/ +#include +#include +#include +#include + +#ifdef PLATFORM_NT +#include +#endif +#ifdef PLATFORM_LINUX +#endif + +#define TRUE 1 +#define FALSE 0 + +#define MODE_RECOGNIZE 0 +#define MODE_TRAIN1 1 +#define MODE_TRAIN2 2 + +void alloc_td_bu(); + + +unsigned char **cimage; +double **tds; +double **bus; +int lwidth,lheight; +int width, height,numinputs; +long i,j; + +int pass_flag; +int highx[2], highy[2]; +double highest_confidence[2]; +int set_high[2]; + +#define DB1 1 +#define DB2 0 +#define DB3 1 + +FILE *fp; + +int winner,numf1s,numf2s, resonant,cp,numpatterns; + +double a, b, c, d, theta, delta_t; +double rho; + +typedef struct { + double *I; + double W; + double X; + double V; + double U; + double P; + double Q; + double R; + } f1_neuron; + +f1_neuron *f1_layer; + +typedef struct { + double y; + int reset; + } xyz; + +xyz *Y; + + +double g(i) +int i; +{ double result; + if (i != winner) + result =0; + else + if ( Y[i].y > 0) + result = d; + else + result =0; + return(result); +} + +void find_match() +{ int i; + winner = 0; + for (i=0;i Y[winner].y) + winner =i; +} + +double simtest() +{ int j; + double sum,norm; + double temp_sum; + + sum = norm =0; + for (j=0;j 0)) + tsum += tds[ti][tj] * d; + } + + f1_layer[ti].P = f1_layer[ti].U + tsum; + + tnorm += f1_layer[ti].P * f1_layer[ti].P; + + if (ttemp != f1_layer[ti].P) + tresult=0; + } + f1res = tresult; + + /* Compute F1 - Q values */ + + tnorm = sqrt((double) tnorm); + for (tj=0;tj Y[winner].y) + winner =ti; + } + + + } +#ifdef DEBUG + if (DB1) print_f12(); + if (DB1) printf("\n num iterations for p to stabalize = %i \n",j); +#endif + match_confidence=simtest(); +#ifdef DEBUG +fprintf(stdout,"rho %e\n",match_confidence); +#endif + if ((match_confidence) > rho) + { +#ifdef DEBUG + if (DB2 && (winner==0)) printf("#%i",winner); +#endif + weightadj(); + matched = 1; + } + else + { Y[winner].y = 0; + Y[winner].reset = 1; +#ifdef DEBUG + if (DB1) printf("#%iN",winner); +#endif + matchtest=0; + for (mt=spot;mt 0)) + tsum += tds[ti][tj] * d; + } + + f1_layer[ti].P = f1_layer[ti].U + tsum; + + tnorm += f1_layer[ti].P * f1_layer[ti].P; + + if (ttemp != f1_layer[ti].P) + tresult=0; + } + f1res = tresult; + + /* Compute F1 - Q values */ + + tnorm = sqrt((double) tnorm); + for (tj=0;tj Y[winner].y) + winner =ti; + } + + + } +#ifdef DEBUG + if (DB1) print_f12(); + if (DB1) printf("\n num iterations for p to stabilize = %i \n",j); +#endif + match_confidence=simtest2(); + if ((match_confidence) > rho) + { + /* If the winner is not the default F2 neuron (the highest one) + * we have a match. + */ + if (winner!=numf2s-1) + { + pass_flag=1; + fprintf(stdout,"F2 neuron %d passes vigilance with a value of %0.4f\n",winner,match_confidence); + print_f12(); + if (match_confidence > highest_confidence[winner]) + { + highest_confidence[winner] = match_confidence; + set_high[winner] = TRUE; + } + } + matched = 1; + } + else + { Y[winner].y = 0; + Y[winner].reset = 1; +#ifdef DEBUG + if (DB1) printf("#%i No",winner); +#endif + matchtest=0; + for (mt=0;mt(height-lheight+1))||(startx>(width-lwidth+1))) + { + fprintf(stderr,"Startx %d or Starty %d is out of range\n", startx, starty); + exit(1); + } + if ((endy>(height-lheight+1))||(endx>(width-lwidth+1))) + { + fprintf(stderr,"endx %d or endy %d is out of range\n", endx, endy); + exit(1); + } +#ifdef DEBUG + if (DB3) + { + fprintf(stdout,"made it to scan_recognize\n"); + fprintf(stdout,"w= %d h = %d lw = %d lh = %d\n",width,height,lwidth,lheight); + } +#endif + for (j=starty;j %s\n",argv[arg_index]); + goto Usage; + } + arg_index+=2; /* this works as long as options are duals!!! */ + } + + /* Some basic error checking. */ + + if (scanfile==NULL) + { + fprintf(stderr,"ERROR: Must specify input files\n"); + goto Usage; + } + if ((weightfile==NULL)&&(trainfile1==NULL)) + { + fprintf(stderr,"ERROR: Must specify weightfile or trainfile1\n"); + goto Usage; + } + if ((weightfile!=NULL)&&(trainfile1!=NULL)) + { + fprintf(stderr,"ERROR: Cannot specify weightfile and trainfile1\n"); + goto Usage; + } + +#ifdef DEBUG + fprintf(stdout,"scanfile = %s\n weightfile = %s\n startx = %d\n starty = %d\n stride = %d\n",scanfile,weightfile,startx,starty,stride); +#endif + + loadimage(scanfile); + + /* Differentiate between loading pretrained network (load_weights) + * and training. Currently, loading a pretrained network + * supports only 1 object. If we train, we can learn to + * recognize two objects. + */ + if (weightfile!=NULL) + { + numpatterns = 1; + if (objects==0) + { + objects = numpatterns; + } + load_weights(weightfile); + init_globs(MODE_RECOGNIZE); + init_net(); + } + else + { + if (trainfile2!=NULL) + { + numpatterns = 2; + if (objects] [-starty ] [-endx ] [-endy ] [-stride ] -scanfile -trainfile1 [-trainfile2 ]\n"); + exit(1); +Version: + fprintf(stderr,"Version 1.00 \n"); + exit(1); +} -- 2.20.1