[comp.ai.neural-nets] Bugs in my back-prop programs

drt@chinet.chi.il.us (Donald Tveter) (10/12/90)

I found two bugs in my back-prop source that was posted in
comp.sources.misc last month.  Both have to do with continuous
updates and not periodic ones.  First, the program will sometimes claim
to have learned the patterns to within the given tolerance when it
hasn't.  When this happens it typically requires one more iteration to
meet the tolerance.  To correct this I have created a procedure
called learncheck.  Add a call to this procedure in the procedure
oneset in the file misc.c after line 336 like so:

      else last->currentpat->bypass = last->currentpat->bypass - 1;
    };
 learncheck();   /* add this line here */
 if (unlearnedpats == 0) return;
 if (attempted == passed)

Then insert this procedure somewhere before the procedure oneset:

 void learncheck() /* needed for continuous updates */
 {
   int i;
   UNIT *u;
   PATNODE *t;
   int unlearned;
   WTTYPE diff, adiff;

   if (unlearnedpats == 0 && (update == 'c' || update == 'C'))
      {
        resetpats();
        for (i=1;i<=npats;i++)
           {
             nextpat();
             setonepat();
             forward();
             u = (UNIT *) last->units;
             t = (PATNODE *) last->currentpat->pats;
             unlearned = 0;
             while (u != NULL)
                {
                  diff = t->val - u->oj;
                  if (diff < 0) adiff = -diff; else adiff = diff;
                  if (adiff > toler) unlearned = 1;
                  u = u->next;
                  t = t->next;
                };
             unlearnedpats = unlearnedpats + unlearned;
          };
      };
}


Second, the real version of continuous updates is not being handled
correctly.  In the procedure cbackinner in the file real.c change
this line:

  if (update == 'D') reta = eta2; else reta = eta;

to:

  if (update == 'C') reta = eta2; else reta = eta;

This error will produce very bad learning behavior for the real
version using the differential step size method and continuous
updates.

Don Tveter
5228 N. Nashville Ave.
Chicago, Illinois   60656
drt@chinet.chi.il.us