diff options
Diffstat (limited to 'neural.c')
-rw-r--r-- | neural.c | 24 |
1 files changed, 13 insertions, 11 deletions
@@ -36,8 +36,15 @@ */ /* -** DEFINES +** LOOP_MAX +** +** This constant sets the max number of loops through the neural +** net that the system will attempt before giving up. This +** is not a critical constant. You can alter it if your system +** has sufficient horsepower. */ +#define LOOP_MAX 500000L + #define T 1 /* TRUE */ #define F 0 /* FALSE */ #define ERR -1 @@ -58,9 +65,6 @@ */ const char *inpath="NNET.DAT"; -/* -** GLOBALS -*/ double mid_wts[MID_SIZE][IN_SIZE]; /* middle layer weights */ double out_wts[OUT_SIZE][MID_SIZE]; /* output layer weights */ double mid_out[MID_SIZE]; /* middle layer output */ @@ -84,9 +88,6 @@ int numpats; /* number of patterns in data file */ int numpasses; /* number of training passes through data file */ int learned; /* flag--if TRUE, network has learned all patterns */ -/* -** PROTOTYPES -*/ static clock_t DoNNetIteration(unsigned long nloops); static void do_mid_forward(int patt); static void do_out_forward(); @@ -122,6 +123,7 @@ DoNNET(void) clock_t total_time = 0; int iterations = 0; static int is_adjusted = FALSE; + static int loops = 1; /* ** Init random number generator. @@ -152,9 +154,9 @@ DoNNET(void) ** # of loops and increasing the loop count until we ** get a number of loops that we can use. */ - for (locnnetstruct->loops = 1; locnnetstruct->loops < MAXNNETLOOPS; locnnetstruct->loops++) { + for (; loops < LOOP_MAX; loops++) { randnum((int32_t)3); - if(DoNNetIteration(locnnetstruct->loops) > MINIMUM_TICKS) { + if(DoNNetIteration(loops) > MINIMUM_TICKS) { break; } } @@ -162,8 +164,8 @@ DoNNET(void) do { randnum((int32_t)3); /* Gotta do this for Neural Net */ - total_time += DoNNetIteration(locnnetstruct->loops); - iterations += locnnetstruct->loops; + total_time += DoNNetIteration(loops); + iterations += loops; } while (total_time < MINIMUM_SECONDS * CLOCKS_PER_SEC); locnnetstruct->results = (double)(iterations * CLOCKS_PER_SEC) / total_time; |