home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast2.iso / neurlnet / nnutl101.zip / NNREADME.DOC < prev    next >
Text File  |  1993-08-02  |  12KB  |  195 lines

  1.                                     NNUTILS.ZIP
  2.               by Gregory Stevens (stevens@prodigal.psych.rochester.edu)
  3.                                      ver 1.01
  4.  
  5.               Tutorial Package Comments, Instructions, Documentation
  6.  
  7. This is a Public Domain package of files that are meant to help you to
  8. get started programming neural networks in C.  In essence, it is a tutorial
  9. about how to program neural networks (or how to program in C, depending on
  10. what you need to learn more), where instead of the tutorial being readable
  11. text, it is readable code.  There are include files here with overdocumented
  12. code that contains everything you need to implement several kinds of net
  13. archetectures.  What you get in this package is a couple text files in
  14. the main directory you unzip to, and then a series of simple implementations
  15. using the include files to let you, step by step, see how they work.
  16.  
  17. In each subdirectory there is source code in C, which will usually consist
  18. of six standard include files for the nnutils library, and a main program
  19. which will have a name similar to that of the directory.  The source is 
  20. written ANSI compliant C and developed primarily under Borland C++ 3.1
  21. developing environment.  Because of this, I have included DOS executables
  22. and project files for each implementation (except one: see BUGS.DOC).  Also,
  23. because the code is all ANSI compliant, all of the compiles under gcc and
  24. runs under UNIX.  This has not been included, but all you need do is put all
  25. the source in a UNIX directory on a machine that has gcc, and type:
  26.  
  27. gcc -O -o executable.filename -lm
  28.  
  29. This sets for maximum optimization, to put the output executable file in
  30. the name executable.filename (changable, obviously), and to include the math
  31. library.
  32.  
  33. To use these you should have a basic understanding of the theory behind
  34. neural networks (and C programming), even if you haven't implemented anything
  35. before.  You should know about layers, activation states, learning and
  36. back-propagation (even if you don't understand the math :-), supervised
  37. versus unsupervised learning, etc.
  38.  
  39. If you don't understand the math behind back-propagation (and even if you do,
  40. possibly!), NNBKPROP.C will be a little cryptic.  Any questions about the
  41. math behind back-propagation or the file, you can email me at
  42. stevens@prodigal.psych.rochester.edu.
  43.  
  44. To learn how to use the tools presented here, I suggest you look at the
  45. code for, alter and run, the following implementations (in order):
  46.  
  47. NNTEST1  -  This is a very simple demonstration.  It is a network with
  48.             one input node and one output node, as you can see from the
  49.             nnparams.c file.  Also, if you look in nnstruct.c at the
  50.             initialization function, you can see that it sets the output
  51.             node's learning function flag to 0, representing a linear
  52.             node.  
  53.              This node basically can learn linear equations.  Try it.
  54.             Give it a series of input numbers in nninputs.dat (make sure
  55.             the number of numbers is the same as the definition of NUMPATTERNS
  56.             in nninputs.c), and put the corresponding y values for a linear
  57.             function in nnoutput.dat.  It will display as it trains, and
  58.             eventually the weight will converge as the x coefficient and
  59.             the threshhold as the y-intercept.  This demonstrates something 
  60.             about the theory behind linear threshhold units, too.
  61.              Try to make the values in nnoutput.dat be non-linear functions
  62.             on the input values.  The net cannot learn them.
  63.  
  64. NNTEST2 - This is a demonstration of what's called the "logistic" activation
  65.           function (as opposed to linear).  This is the kind of function
  66.           generally used, because it can approximate both linear and
  67.           stepwise activation functions.  The current nninputs.dat and
  68.           nnoutput.dat train it to mimick a threshhold unit.  You can play
  69.           with these at will.
  70.  
  71. NNXOR - This is an implementation of the famous Exclusive Or problem.
  72.          Though both of the tests use back-propagation for learning, this
  73.          is the first one that has needed hidden units.  It is set up with
  74.          the standard archetecture for solving XOR (2 input,2 hidden,1 output)
  75.          and the inputs and output files have been set up accordingly.  It 
  76.          takes a while.  Be patient.
  77.  
  78. NNSIM1 - After this you are ready to look at general simulator number 1. This
  79.         allows you flexibility to modify it into any kind of feed-forward
  80.         network with backpropagation as the learning algorithm.  It contains
  81.         what you need to train a net, as well as adding the file NNINTEST.DAT
  82.         as novel patterns to expose to the net after training, with a Boolean
  83.         to turn on or off the option of exposing the net to these novel
  84.         patterns.
  85.          Please play with this.  There are a lot of variables to be altered.
  86.         Right now, in the distribution package, it should be a cheesy little
  87.         net that I interprete as a rhythm detector.  The input layer is 
  88.         eight nodes, with the input patterns representing one measure of
  89.         eight eighth notes positions, with 1's representing a beat, 0's
  90.         representing rests.  The output layer has one node, which is on (1)
  91.         if it is a "good" rhythm (likeable), and 0 (off) otherwise.  There
  92.         should be 10 good rhythms coded in the first ten input patterns,
  93.         with the first 10 numbers in the nnoutput.dat being 1's, followed
  94.         by 10 bad rhythms (10 zero's in nnoutput.dat).  This trains to
  95.         recognize good from bad rhythms.  Then, the nnintest.dat presents
  96.         20 novel rhythms to see if the net generalized the way people do.
  97.          It's kinda neat.  But, you can have your input and output patterns
  98.         represent anything you want.  Play, please.
  99.          Things to note:  This displays every pattern as it is introduced
  100.         to the net, and pauses the display for keyboard trigger for the
  101.         last 10 sets of training patterns.  You can suppress output by
  102.         putting the DisplayLayer functions and other output stuff in an
  103.         if condition and have it only display the last trials.
  104.           If you change the layer sizes, you will want to change the last
  105.         number in DisplayLayer, which is the formatting function.  If would
  106.         have made it prettier with gotoxy()'s, but I wanted it runable on 
  107.         UNIX.  If you make a DOS display function with gotoxy's, send
  108.         them to me, and I will put them in the next version in the file
  109.         NNDISPLY.C.  Don't put them there yourself, however, because I will
  110.         be wanting to use pre-compiler commends to be able to skip past them
  111.         when run on a UNIX machine.
  112.  
  113. NNWHERE - Now that you have played with the general simulator a bit, you
  114.         are ready to look at some specific applications.  This implements
  115.         a net based on part of a model described in a paper that is cited 
  116.         in the introductory comments of the source code.  It is basically
  117.         part of a 2-test project, where there is a 5x5 retina presented with
  118.         shapes in different positions, and the NNWHERE half of it has to
  119.         learn to classify the position of different objects (thus learn a
  120.         classification independant of shape of the pattern).  This it 
  121.         learns quite easily, and will run quite well.
  122.  
  123. NNWHAT - This half of the experiment is more complex.  This is designed to
  124.         learn which shape is being presented, independant of _position_.
  125.         Computationally, this is a much more difficult task, and needs a
  126.         hidden layer with many units.
  127.          However, as you will read in bugs.doc, there are problems with the
  128.         size of the structure running under Borland under DOS.  Compile it
  129.         under UNIX and it runs with no problem.  If you find out how to get 
  130.         this to go on a DOS machine, please tell me.
  131.  
  132. NNEVOLVE - Finally (for the feed-forward, back-propagation supervised nets)
  133.           this last thing is a slight hand-tweaking for an experiment I did
  134.           to show representation independance in distributed systems.  My
  135.           idea for the experiment is all documented in nnevolve.doc, and
  136.           the output of my run of the experiment are in gens1.zip.  All you
  137.           need to do to reproduce my experiment is run evolve.bat.  You can
  138.           figure out what it's doing from the documentation and code yourself.
  139.  
  140. NOTE: All of the previous have been supervised learning implementations using
  141.       back-propagation.  They all #include nnbkprop.c, and they all need
  142.       the files nninputs.dat as the input training patterns and nnoutput.dat
  143.       as the "what the answers should be" patterns.  There are two other
  144.       kinds of error-correction with neural networks: unsupervised and
  145.       reward-based learning.  Reward learning is not covered here, because it
  146.       is similar to Hebbian learning in conception, but there are so many 
  147.       methods for calculating reward, and so many difficulties with dealing
  148.       with delayed reward, that it is beyond the scope of this library.
  149.  
  150.       The following file is an example of the routines for feed-foreward,
  151.       UNsupervised learning (with Hebbian learning algorithm).  To use just
  152.       standard Hebbian learning, include "nnhebbln.c" in your main file.
  153.       To use competative learning, include "nncompet.c" instead.
  154.  
  155.       ** I plan on writing more implementations for unsupervised nets, and
  156.       will distribute updates.  However, if you are feeling inventive and
  157.       want to write a neat variation/implementation, send it to me and I
  158.       will include it with a new release, with all of your credit info. **
  159.  
  160. NNSIM2 - This is a general simulation of a competative learning network with 
  161.       a hebbian learning algorithm.  To change this to a Hebbian learning
  162.       algorithm (not winner-take-all competative learning), simply comment
  163.       out the call to the function AllOrNoneLayerActs().  To change it
  164.       permanently in a program, simply  delete that line, and change the
  165.       include file from nncompet.c to nnhebbln.c.
  166.        I'm not sure, but I think this simulation has some bugs, which may
  167.       be in nncompet.c, nnhebbln.c, or the main nnsim2.c itself.  See
  168.       BUGS.DOC for more information.
  169.  
  170. NOTE: All of the previous networks have been feed foreward networks.  They
  171.       all follow the same basic format in the main body of the program. 
  172.       However, there is another kind of net: recurrent networks.
  173.  
  174.       The following file is a basic little recurrent network that learns an
  175.       internal representation in the hidden units of a sequence of numbers.
  176.       It has one input, and one output, designed to work with back-propagation
  177.       self-correlating (output node equals input node) and a number of context
  178.       units equal to the size of the hidden layer.  It displays the hidden
  179.       layer so you can see the pattern it learns.
  180.  
  181. NNRECUR1 - This is an example of a recurrent net with back-propagation
  182.       (a kind of supervised learning called Self-Correlating, where the
  183.       input patterns serve as their own output patterns).  It goes through
  184.       all possible three-bit patterns, and feeds them in one-by-one, and
  185.       the hidden layer learns a representation of the entire strings through
  186.       time.  Values of patterns are 1.0 or 0.0, empty values (before beginning
  187.       and afte ending of patterns) is 0.5.  It takes a while.
  188.  
  189. -------------------------------------------------------------------------------
  190. That's it for now.  Keep in touch.
  191.  
  192. greg
  193.  
  194. stevens@prodigal.psych.rochester.edu
  195.