home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / ai / neuraln / 3203 < prev    next >
Encoding:
Text File  |  1992-08-15  |  14.0 KB  |  384 lines

  1. Newsgroups: comp.ai.neural-nets
  2. Path: sparky!uunet!utcsri!torn!newshost.uwo.ca!gaul.csd.uwo.ca!koops
  3. From: koops@gaul.csd.uwo.ca (Luke Koops)
  4. Subject: Reducing Training time (summary)
  5. Organization: Computer Science Dept., Univ. of Western Ontario, London, Canada
  6. Date: Sun, 16 Aug 1992 06:38:25 GMT
  7. Message-ID: <1992Aug16.063825.15300@julian.uwo.ca>
  8. Keywords: back propagation, training
  9. Sender: news@julian.uwo.ca (USENET News System)
  10. Nntp-Posting-Host: obelix.gaul.csd.uwo.ca
  11. Lines: 371
  12.  
  13. A while ago I posted a request asking how I could reduce the training
  14. time for a back-propagation neural network, and recieved these helpful
  15. respones.
  16.  
  17.  
  18. From styri@balder.nta.no Mon Aug 10 08:00 EDT 1992
  19.  
  20. One way of reducing training time is to use a faster implementation...
  21. There's an implementation by Dr. Donald Tveter in several archives,
  22. this suite of s/w includes an integer (or rather fixed point math)
  23. implementation of the bp algorithm. Worth trying.
  24.  
  25. Your method of training is, however, a bit too simple. Training time
  26. depends on a lot of factors: the momentum and learning rate, and the
  27. initial weights - just to mention the most important. Just increasing
  28. the number of nodes in the hidden layer may even lead to a poor net.
  29.  
  30. ---
  31. Haakon Styri
  32. Norwegian Telecom Research
  33.  
  34.     [note:  number of nodes is increased until a solution is found
  35.             if the net overgeneralizes, that's not my problem]
  36.  
  37.  
  38.  
  39. From peterhi@syma.sussex.ac.uk Mon Aug 10 08:31 EDT 1992
  40. Organization: University of Sussex
  41.  
  42. Being pragmatic I would say that you should use a binary search for the number
  43. of hidden nodes. Start at 5, if that trains then try 3 if that fails go up to
  44. 4 and so on. You can ask any half decent Comp-Sci BSc about binary searches.
  45. As to the order try this heuristic...
  46.  
  47. Have the training set sequenced so as to have the greatest difference in
  48. output and least difference in input from one vector to the next. This is
  49. assuming that the training set is being accessed linearly and not at random.
  50. There are more incorrect orderings that there are correct ones. (By the way
  51. the method of ordering the data is NP-Complete and therefore I can offer you
  52. no code to do this for you - sorry). If you could get be a SERC fund I'll look
  53. into it for you :)
  54.  
  55. How big is the training set? Could you mail it to me?
  56.  
  57. Peter Hickman
  58. -- 
  59. --------------------------------------- peterhi@uk.ac.sussex.syma ------------
  60.       "More beer, more shouting, resistance is useless" - USTA bars
  61.  
  62.  
  63.  
  64. From rilbe@elixir.e.kth.se Mon Aug 10 08:36 EDT 1992
  65.  
  66. Scott E. Fahlman at Carnegie-Mellon has written a report called "An Empirical 
  67. Study of Learning Speed in Back-Propagation Networks". It is available by ftp
  68. at archive.cis.ohio-state.edu under /pub/neuroprose as fahlman.quickprop-tr.ps.Z.
  69.  
  70. In this report he provides training times for tight encoder problems of different
  71. sizes and with different parameter values.
  72.  
  73. He proposes different error functions and he presents a new algorithm which he 
  74. calls quick-prop (you may have heard of it?). 
  75.  
  76. I have changed the PDP bp program to use the quick-prop algorithm instead of
  77. plain old bp. It works just fine. Here is my changed piece of code:
  78.  
  79. /* The quickprop algorithm developed by Scott Fahlman at Carnegie-Mellon. */
  80. change_weights_follow() {
  81.     register int   i;
  82.     register float *wt, *dwt, *epi, *wi, *end, *pwi, growth;
  83.     float          tb, dp, den;
  84.  
  85.     p_css = css;
  86.     css = 0.0;
  87.     dp = 0.0;
  88.     
  89.     link_sum();
  90.  
  91.     for (i=ninputs+ndelays; i<nunits; i++) {
  92.       tb = bed[i];
  93.       dbias[i] = tb*bepsilon[i]+momentum*dbias[i];
  94.       bias[i] += dbias[i];
  95.       css += ((double) tb)*((double) tb); 
  96.       dp += ((double) tb)*((double) pbed[i]); 
  97.       pbed[i] = tb;
  98.       bed[i] = 0.0;
  99.       wt = weight[i];
  100.       dwt= dweight[i];
  101.       wi = wed[i];
  102.       pwi = pwed[i];
  103.       wed[i] = pwi;
  104.       pwed[i] = wi;
  105.       epi = epsilon[i];
  106.       end = wt+num_weights_to[i];
  107.       for (; wt<end; wt++, dwt++, wi++, pwi++, epi++) {
  108.         if (fabs(*wi)>=fabs(*pwi) && signbit(*wi)==signbit(*pwi))
  109.       growth = maxgrowth;
  110.     else {
  111.       growth = (*wi)/((*pwi)-(*wi));
  112.       if (fabs(growth)>maxgrowth) growth = copysign(maxgrowth,growth);
  113.     }
  114.     *dwt = growth*(*dwt);
  115.     if (signbit(*wi)==signbit(*pwi)) *dwt += (*epi)*(*wi);
  116.     *wt += *dwt;
  117.     if (fabs(*wt)>maxweight) *wt = copysign(maxweight,*wt);
  118.     css += ((double) (*wi))*((double) (*wi)); 
  119.     dp += ((double) (*wi))*((double) (*pwi)); 
  120.     *pwi = 0.0;
  121.       }
  122.     }
  123.  
  124.     den = p_css*css;
  125.     if (den > 0.0) gcor = dp/(sqrt(den));
  126.     else gcor = 0.0;
  127.  
  128.     pos_neg_constraints();
  129. }
  130.  
  131.  
  132.  
  133. The variables "maxgrowth" and "maxweight" should be installed into the menu
  134. system of the PDP software using the "install_var" function. (Study the bp file
  135. to see how it is done.) 
  136.  
  137. Another change which is easy to implement is to add 0.1 to the sigmoid-prime
  138. function. This is also suggested in the report mentioned above. To do this, 
  139. study the "compute_error". Change "act*(1-act)" to "0.1+act*(1-act)".
  140.  
  141. I hope you will get better performance with these changes.
  142. The report does also, as mentioned above, indicate optimal parameter values for 
  143. ordinary bp which you could try out.
  144.  
  145. Leif Rilbe
  146. rilbe@elixir.e.kth.se
  147.  
  148.  
  149.  
  150.  
  151. From Scott_Fahlman@SEF-PMAX.SLISP.CS.CMU.EDU Mon Aug 10 10:22 EDT 1992
  152.  
  153. Luke,
  154.  
  155. You may have seen this stuff already, since I recently posted a pointer to
  156. it.  In any case, you really should know about it, given the project that
  157. you are doing.  Your method of finding the right architecture by gradually
  158. increasing a single hidden layer was, as far as I know, first done by Timur
  159. Ash (see citations in the Cascor paper).  Too bad it's near the end of your
  160. experiment and not the start...
  161.  
  162. -- Scott
  163. ===========================================================================
  164. Scott E. Fahlman
  165. School of Computer Science
  166. Carnegie Mellon University
  167. 5000 Forbes Avenue
  168. Pittsburgh, PA 15213
  169.  
  170. Internet: sef+@cs.cmu.edu
  171. ===========================================================================
  172. Public-domain simulation programs for the Quickprop, Cascade-Correlation,
  173. and Recurrent Cascade-Correlation learning algorithms are available via
  174. anonymous FTP on the Internet.  This code is distributed without charge on
  175. an "as is" basis.  There is no warranty of any kind by the authors or by
  176. Carnegie-Mellon University.
  177.  
  178. Instructions for obtaining the code via FTP are included below.  If you
  179. can't get it by FTP, contact me by E-mail (sef+@cs.cmu.edu) and I'll try
  180. *once* to mail it to you.  Specify whether you want the C or Lisp version.
  181. If it bounces or your mailer rejects such a large message, I don't have
  182. time to try a lot of other delivery methods.
  183.  
  184. I would appreciate hearing about any interesting applications of this code,
  185. and will try to help with any problems people run into.  Of course, if the
  186. code is incorporated into any products or larger systems, I would
  187. appreciate an acknowledgement of where it came from.
  188.  
  189. If for some reason these programs do not work for you, please contact me
  190. and I'll try to help.  Common errors: (1) Some people don't notice that the
  191. symmetric sigmoid output units in cascor have a range of -0.5 to +0.5 (for
  192. reasons that are mostly historical).  If you try to force this algorithm to
  193. produce an output of +1.0 or +37.3, it isn't going to work.  (2) Note that
  194. quickprop (which is used inside of Cascade-Correlation) is designed to
  195. update the weights after every epoch, and it assumes that all the epochs
  196. are identical.  If you try to run this code updating after every training
  197. case, you will lose badly.  If you want to change the training set, it is
  198. important to zero out the PREV-SLOPES and DELTAS vectors, and also to
  199. re=build the caches in Cascade-Correlation.
  200.  
  201. HOW TO GET IT:
  202.  
  203. For people (at CMU, MIT, and soon some other places) with access to the
  204. Andrew File System (AFS), you can access the files directly from directory
  205. "/afs/cs.cmu.edu/project/connect/code".  This file system uses the same
  206. syntactic conventions as BSD Unix: case sensitive names, slashes for
  207. subdirectories, no version numbers, etc.  The protection scheme is a bit
  208. different, but that shouldn't matter to people just trying to read these
  209. files.
  210.  
  211. For people accessing these files via FTP:
  212.  
  213. 1. Create an FTP connection from wherever you are to machine
  214. "ftp.cs.cmu.edu".  The internet address of this machine is 128.2.206.173,
  215. for those who need it.
  216.  
  217. 2. Log in as user "anonymous" with your own ID as password.  You may see an
  218. error message that says "filenames may not have /.. in them" or something
  219. like that.  Just ignore it.
  220.  
  221. 3. Change remote directory to "/afs/cs/project/connect/code".  NOTE: You
  222. must do this in a single operation.  Some of the super directories on this
  223. path are protected against outside users.
  224.  
  225. 4. At this point FTP should be able to get a listing of files in this
  226. directory with DIR and fetch the ones you want with GET.  (The exact FTP
  227. commands you use depend on your local FTP server.)
  228.  
  229. Current contents:
  230.  
  231. quickprop1.lisp        Original Common Lisp version of Quickprop.
  232. quickprop1.c        C version by Terry Regier, U. Cal. Berkeley.
  233. cascor1.lisp        Original Common Lisp version of Cascade-Correlation.
  234. cascor1.c        C version by Scott Crowder, Carnegie Mellon
  235. rcc1.lisp        Common Lisp version of Recurrent Cascade-Correlation.
  236. rcc1.c            C version, trans. by Conor Doherty, Univ. Coll. Dublin
  237. vowel.c            Code for Tony Robinson's vowel benchmark.
  238. am4.tar.Z        Aspirin/Migraine code from MITRE.
  239. backprop.lisp        Overlay for quickprop1.lisp.  Turns it into backprop.
  240. ---------------------------------------------------------------------------
  241. Tech reports describing these algorithms can also be obtained via FTP.
  242. These are Postscript files, processed with the Unix compress/uncompress
  243. program.
  244.  
  245. unix> ftp ftp.cs.cmu.edu (or 128.2.206.173)
  246. Name: anonymous
  247. Password: <your user id>
  248. ftp> cd /afs/cs/project/connect/tr
  249. ftp> binary
  250. ftp> get filename.ps.Z
  251. ftp> quit
  252. unix> uncompress filename.ps.Z
  253. unix> lpr filename.ps   (or however you print postscript files)
  254.  
  255. For "filename", sustitute the following:
  256.  
  257. qp-tr            Paper on Quickprop and other backprop speedups.
  258. cascor-tr        Cascade-Correlation paper.
  259. rcc-tr            Recurrent Cascade-Correlation paper.
  260. precision        Hoehfeld-Fahlman paper on Cascade-Correlation with
  261.             limited numerical precision.
  262. ---------------------------------------------------------------------------
  263. The following are the published conference and journal versions of the
  264. above (in some cases shortened and revised):
  265.  
  266. Scott E. Fahlman (1988) "Faster-Learning Variations on Back-Propagation: An
  267. Empirical Study" in (\it Proceedings, 1988 Connectionist Models Summer
  268. School}, D. S. Touretzky, G. E. Hinton, and T. J. Sejnowski (eds.),
  269. Morgan Kaufmann Publishers, Los Altos CA, pp. 38-51.
  270.  
  271. Scott E. Fahlman and Christian Lebiere (1990) "The Cascade-Correlation
  272. Learning Architecture", in {\it Advances in Neural Information Processing
  273. Systems 2}, D. S. Touretzky (ed.), Morgan Kaufmann Publishers, Los Altos
  274. CA, pp. 524-532.
  275.  
  276. Scott E. Fahlman (1991) "The Recurrent Cascade-Correlation Architecture" in
  277. {\it Advances in Neural Information Processing Systems 3}, R. P. Lippmann,
  278. J. E. Moody, and D. S. Touretzky (eds.), Morgan Kaufmann Pulishers, Los
  279. Altos CA, pp. 190-196.
  280.  
  281. Marcus Hoehfeld and Scott E. Fahlman (1992) "Learning with Limited
  282. Numerical Precision Using the Cascade-Correlation Learning Algorithm" in
  283. IEEE Transactions on Neural Networks, Vol. 3, no. 4, July 1992, pp.
  284. 602-611.
  285.  
  286.  
  287.  
  288.  
  289. From neal@stat.washington.edu Mon Aug 10 17:03 EDT 1992
  290. Organization: U. Washington Dept. of Statistics
  291.  
  292. I have found that a quick speed up can be done 
  293. if you have floating point values is to normalize
  294. the data by computing the mean and standard deviation
  295. of each column and then , for each member of the column
  296. replace it by it's z-score. In C it would look something
  297. like this:
  298.  
  299.  
  300.     for(j=0;j<ncols;j++);
  301.     {
  302.         .
  303.         .
  304.         compute mean[j] and sd[j]
  305.         .
  306.         .
  307.  
  308.     for(i=0;i<nrows;i++)
  309.     {
  310.     observation[i][j] = observation[i][j]-mean[j])/sd[j]
  311.     }
  312.     }
  313.  
  314. Then dump your observations into the bp nn.
  315.  
  316. Good Luck.
  317.  
  318. Phil Neal
  319.  
  320.  
  321.  
  322.  
  323. From chinet!drt@clout.chi.il.us Wed Aug 12 10:59 EDT 1992
  324. From: drt@chinet.chi.il.us (Donald Tveter)
  325.  
  326. I've been puttering with simple backprop improvements for some time.  I've
  327. posted the source in comp.sources.misc in February and it should be available
  328. from any site that stores that group or I could email you the cC code (for UNIX,
  329. 16-bit DOS and 32-bit DOS).
  330.  
  331. If you're not interested in that here are the simplest things you can do which
  332. will also make a big difference:
  333.  
  334. 1) fudge the derivative in the output layer.  Change it from s(1-s) to 1. This
  335.    will probably require you to use a much smaller eta and you may need an
  336.    even smaller value for the lower layer.  (This is called the differential
  337.    step size method.)
  338.  
  339. 2) Sometimes changing the activation function to 1 /(1 + exp(-Dx)) helps.
  340.    Normally the best value for D is greater than 1 but sometimes it works
  341.    best for D < 1.
  342.  
  343. 3) Add direct connections from the input layer to the output layer.
  344.  
  345. Don Tveter
  346. drt@chinet.chi.il.us
  347.  
  348.  
  349.  
  350.  
  351.  
  352.     [ from Luke koops:
  353.  
  354.     Unfortunately I did not take advantage of any of the aforementioned
  355.     techniques for speeding up training.  This was because I found a
  356.     simple way to improve my training times.  There was a vast increase in
  357.     training speed when I switched from training by epoch to training by
  358.     pattern.  This improvement was sufficient for me.
  359.  
  360.     I noticed that the performance of neural networks was degraded when
  361.     the training set became too large.  The test set had a size of 1024
  362.     patterns and the training set was chosen from this set with
  363.     repetition.  When I made a training set consisting of about 2400
  364.     examples (representing approx.  90% unique instances of the test set),
  365.     the backprop network failed to learn.  This is a counter intuitive
  366.     result.  You would think that increasing the amount of information
  367.     available would improve learning.  I suspect that the error
  368.     derivatives that were accumulated over the feedforward phase of
  369.     training tended to cancel eachother out, thus creating large local
  370.     minima that represent poor generalizations.  I guess this would be
  371.     an example of "under fitting" the data. ]
  372.  
  373.  
  374.    Thanks for all your help, and interesting suggestions.
  375.  
  376.    -Luke Koops (koops@csd.uwo.ca)
  377.  
  378.  
  379. -- 
  380.     /
  381. ***/
  382. *\/* koops@csd.uwo.ca
  383. ****
  384.