-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquickprop1.c
789 lines (681 loc) · 22.8 KB
/
quickprop1.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
/* This is Scott Fahlman's quickprop program translated from Common Lisp
* into C by Terry Regier at the University of California, Berkeley.
* Netmail address: [email protected]
* This version is Quickprop 1 from September, 1988.
*
* An example of network setup data is included at the end of this file.
*
* The algorithm and some test results are described in Fahlman's paper
* "Faster-Learning Variations on Back-Propagation: An Empirical Study"
* in Proceedings of 1988 Connectionist Models Summer School, published
* by Morgan Kaufmann.
*
* Note: the parameter called "mu" in the paper is called "max-factor" here.
*
* Changes made to quickprop.c version 1 by N Karunanithi netmail:
* <[email protected]>.
*
* Connections can now be specified for multiple ranges of units.
* For example if you had 3 layers of hidden units and wanted the
* third layer to have connections to inputs and the second layer,
* but not the first hidden layer.
*
* Bug fix in CONNECT_LAYERS by Richard Dale Romero <[email protected]>
* inserted into the code on September 18, 1991
*
* You may specify hidden and output units as sigmoids with ranges
* of -0.5 to 0.5 (SIGMOIDAL) or from 0.0 to 1.0 (ASYMSIGMOIDAL) in
* the input file.
*/
#include <stdio.h>
#include <math.h>
#define N 30 /* Max number of units allowed in net */
#define SIGMOID 1 /* Unit_type is SIGMOID with output = +0.5 to -0.5 */
#define ASYMSIGMOID 2 /* ASYMSIGMOID with output = 0.0 to 1.0 */
/* Global variables */
int Epoch; /* Current epoch number */
float WeightRange; /* Random-init weights in range [-WR,+WR] */
float SigmoidPrimeOffset; /* Add to sigmoid-prime to kill flat spots */
int HyperErr; /* 1 => use atanh error function */
int SplitEpsilon; /* 1 => divide epsilon by fan-in before use */
float Epsilon; /* For grad descent if last step was (almost) 0 */
float Momentum; /* Normal old momentum term */
float ModeSwitchThreshold; /* Inside thresh, do grad descent; outside, jump. */
float MaxFactor; /* Don't jump more than this times last step */
float Decay; /* Weight decay */
int SinglePass; /* 1 => Pause after forward/backward cycle */
int SingleEpoch; /* 1 => Pause after each training epoch */
int Step; /* Turned to 1 after each pause, briefly */
int Restart; /* 1 => restart when max epochs reached */
int KeepScore; /* 1 => accumulate error score for each epoch */
float TotalError; /* Total output error for one epoch */
float ScoreThreshold; /* This close to desired value => bit is correct */
int TotalErrorBits; /* Total # bits in epoch that were wrong */
int DidGradient; /* Total # patterns that did gradient descent */
int Nunits; /* Total number of units in net */
int Ninputs; /* Number of input units */
int FirstHidden; /* Index of 1st hidden unit */
int Nhidden; /* Number of hidden units */
int FirstOutput; /* Index of 1st output unit */
int Noutputs; /* Number of output units */
int Unit_type; /* Type of hidden and Output Units: 1=> SIGMOID,and
2 => ASYMSIGMOID */
float Outputs[N]; /* Final output value for each unit */
float ErrorSums[N]; /* Total error activation for each unit */
float Errors[N]; /* Final error value for each unit */
int Nconnections[N]; /* # of INCOMING connections per unit */
int Connections[N][N]; /* C[i][j] lists jth unit projecting to unit i */
float Weights[N][N]; /* W[i][j] holds weight of C[i][j] */
float DeltaWeights[N][N]; /* Change between previous weight and current one */
float Slopes[N][N]; /* Accumulated slope value for each position */
float PrevSlopes[N][N]; /* Similarly, for the last position visited */
int NTrainingPatterns; /* !! Not in Lisp version. Needed here. */
int NTestPatterns; /* !! Not in Lisp version. Needed here. */
float TrainingInputs[200][N];
float TrainingOutputs[200][N];
float TestInputs[200][N];
float TestOutputs[200][N];
float tinputs[N]; /* Input vector to be tested. */
main ()
{
long seed;
long lrand48();
int i, j, epox, response;
float RANDOM_WEIGHT();
char fname[80];
/* Start up the random number generator */
printf ("Enter seed for random number generator: ");
scanf ("%d", &seed);
srand(time(0));
INITIALIZE_GLOBALS();
/* Get network */
printf ("Enter name of network: ");
scanf ("%s", fname);
GET_NETWORK_CONFIGURATION(fname);
printf ("Want to retrieve old weights [0=>no, 1=>yes]? ");
scanf ("%d", &response);
if ( response )
GET_WEIGHTS(fname);
/* Train the sucker. */
epox = 34;
while ( epox != 0 )
{
printf ("Enter number of epochs to train: ");
scanf ("%d", &epox);
if ( epox != 0 )
TRAIN ( epox );
}
/* Test the sucker. */
printf ("Want to test [0=>no, 1=>yes]? ");
scanf ("%d", &response);
if ( response != 0 )
TEST();
printf ("Want to dump weights [0=>no, 1=>yes]? ");
scanf ("%d", &response);
if ( response )
DUMP_WEIGHTS ( fname );
}
/*
* Get and initialize a network.
*/
GET_NETWORK_CONFIGURATION(fname)
char fname[];
{
FILE *infile, *fopen();
char junk[5][80];
char stringjunk[80];
char realfname[80];
char c;
int temp[10], i, j, connect;
sprintf (realfname, "%s.net", fname);
infile = fopen ( realfname, "r" );
c = 'c'; /* Discard leading comments */
//while (c != '#')
// fscanf (infile, "%c", &c);
/* Get numbers of inputs, hidden units, and output units */
fscanf (infile, "%s %d %s %d %s %d",
junk[0], &temp[0], junk[1], &temp[1], junk[2], &temp[2]);
BUILD_DATA_STRUCTURES( temp[0], temp[1], temp[2] );
/* Get the type units used in hidden and outpt layers. */
fscanf (infile, "%s %d ", junk[0], &temp[0]);
if (temp[0] == 1)
Unit_type = SIGMOID;
else if (temp[0] == 2)
Unit_type = ASYMSIGMOID;
/* Connect layers. */
fscanf (infile, "%s %d", junk[0], &connect);
for (i=0; i<connect; i++) /* Reading CONNECT_LAYERS lines */
{
fscanf (infile, "%d %d %d %d",
&temp[0], &temp[1], &temp[2], &temp[3]);
CONNECT_LAYERS ( temp[0], temp[1], temp[2], temp[3] );
}
/* Read in number of training patterns, then patterns themselves */
fscanf (infile, "%s %d", junk[0], &NTrainingPatterns);
for (i=0; i<NTrainingPatterns; i++)
{
for (j=0; j<Ninputs; j++)
fscanf (infile, "%f", &TrainingInputs[i][j]);
for (j=0; j<Noutputs; j++)
fscanf (infile, "%f", &TrainingOutputs[i][j]);
}
/* Read in number of test patterns, then patterns themselves */
fscanf (infile, "%s %d", junk[0], &NTestPatterns);
for (i=0; i<NTestPatterns; i++)
{
for (j=0; j<Ninputs; j++)
fscanf (infile, "%f", &TestInputs[i][j]);
for (j=0; j<Noutputs; j++)
fscanf (infile, "%f", &TestOutputs[i][j]);
}
fclose(infile);
}
/*
* Dump weights in the specified file.
*/
DUMP_WEIGHTS(fname)
char fname[];
{
FILE *outfile, *fopen();
int i, j;
char realfname[80];
/* Dump weights */
sprintf (realfname, "%s.wts", fname);
outfile = fopen ( realfname, "w" );
for (i=0; i<N; i++)
for (j=0; j<N; j++)
if ( Weights[i][j] != 0.0 )
fprintf (outfile, "%d %d %f ", i, j, Weights[i][j]);
fprintf (outfile, "%d %d %f ", -1, -1, -1.0); /* Signal EOF */
fclose (outfile);
}
/*
* Get weights from the specified file.
*/
GET_WEIGHTS(fname)
char fname[];
{
FILE *infile, *fopen();
int i, j;
float inweight;
char realfname[80];
/* Get weights */
sprintf (realfname, "%s.wts", fname);
infile = fopen ( realfname, "r" );
for (i=0; i<N; i++)
for (j=0; j<N; j++)
Weights[i][j] = 0.0; /* Default weight */
i = 11; /* Arbitrary +ive */
while ( i >= 0 )
{
fscanf (infile, "%d %d %f", &i, &j, &inweight);
if ( i >= 0 )
Weights[i][j] = inweight;
}
fclose (infile);
}
INITIALIZE_GLOBALS()
{
Unit_type = SIGMOID;
Epoch = 0;
WeightRange = 0.7;
SigmoidPrimeOffset = 0.1;
HyperErr = 1;
SplitEpsilon = 1;
Epsilon = 0.55; /* 1.0 */
Momentum = 0.9; /* 0.0 */
ModeSwitchThreshold = 0.0;
MaxFactor = 1.75; /* 1.75 */
Decay = -0.0001; /* -0.0001 */
SinglePass = SingleEpoch = 0;
Step = KeepScore = 0;
Restart = 1;
TotalError = 0.0;
ScoreThreshold = 0.35;
TotalErrorBits = 0;
}
BUILD_DATA_STRUCTURES (ninputs, nhidden, noutputs)
int ninputs, nhidden, noutputs;
{
int i;
Nunits = 1 + ninputs + nhidden + noutputs;
Ninputs = ninputs;
FirstHidden = 1 + ninputs;
Nhidden = nhidden;
FirstOutput = 1 + ninputs + nhidden;
Noutputs = noutputs;
for (i=0; i<=Nunits; i++) Outputs[i] = 0.0;
for (i=0; i<=Nunits; i++) ErrorSums[i] = 0.0;
for (i=0; i<=Nunits; i++) Errors[i] = 0.0;
for (i=0; i<=Nunits; i++) Nconnections[i] = 0;
Outputs[0] = 1.0; /* The bias unit */
}
/*
* Return a float between -range and +range.
*/
float RANDOM_WEIGHT (range)
float range;
{
return ( (float) (range * (rand()%1000 / 500.0)) - range );
}
/*
* Build a connection from every unit in range1 to every unit in range2.
* Also add a connection from the bias unit (unit 0) to every unit in
* range2. Set up random weights on links.
*/
CONNECT_LAYERS (start1, end1, start2, end2)
int start1, end1, start2, end2;
{
int n, i, j, k;
Epoch = 0;
for (i=start2; i<=end2; i++)
{
if(Nconnections[i] == 0){
Nconnections[i] += 1;
Connections[i][0] = 0;
Weights[i][0] = RANDOM_WEIGHT(WeightRange);
DeltaWeights[i][0] = 0.0;
Slopes[i][0] = 0.0;
PrevSlopes[i][0] = 0.0;
k = 1;
}
else
k = Nconnections[i];
/* k = start1; Bug found by
Richard Dale Romero <[email protected]> */
for (j=start1; j<=end1; j++){
Nconnections[i] += 1;
Connections[i][k] = j;
Weights[i][k] = RANDOM_WEIGHT(WeightRange);
DeltaWeights[i][k] = 0.0;
Slopes[i][k] = 0.0;
PrevSlopes[i][k] = 0.0;
k++;
}
}
}
/*
* For each connection, select a random initial weight between WeightRange
* and its negative. Clear delta and previous delta values.
*/
INIT_WEIGHTS()
{
int i, j;
for (i=0; i<Nunits; i++)
for (j=0; j<Nconnections[i]; j++)
{
Weights[i][j] = RANDOM_WEIGHT(WeightRange);
DeltaWeights[i][j] = 0.0;
Slopes[i][j] = 0.0;
PrevSlopes[i][j] = 0.0;
}
}
/*
* Save the current slope values as PrevSlopes, and "clear" all current
* slopes (actually set to corresponding weight, decayed a bit).
*/
CLEAR_SLOPES()
{
int i, j;
for (i=FirstHidden; i<Nunits; i++)
for (j=0; j<Nconnections[i]; j++)
{
PrevSlopes[i][j] = Slopes[i][j];
Slopes[i][j] = ( Decay * Weights[i][j] );
}
}
/*
* Given the sum of weighted inputs, compute the unit's activation value.
* Defined unit types are SIGMOID and ASYMSIGMOID.
*/
float ACTIVATION(sum)
float sum;
{
switch(Unit_type){
case SIGMOID:
/* Symmetrical sigmoid function in range -0.5 to +0.5. */
if (sum < -15.0)
return(-0.5);
else if (sum > 15.0)
return(0.5);
else
return (1.0 /(1.0 + exp(-sum)) - 0.5);
case ASYMSIGMOID:
/* asymmetrical sigmoid function in range 0.0 to 1.0. */
if (sum < -15.0)
return(0.0);
else if (sum > 15.0)
return(1.0);
else
return (1.0 /(1.0 + exp(-sum)));
}
}
/*
* Given the unit's activation value and sum of weighted inputs, compute
* the derivative of the activation with respect to the sum. Defined unit
* types are SIGMOID and ASYMSIGMOID.
*/
float ACTIVATION_PRIME(value)
float value;
{
switch(Unit_type){
case SIGMOID:
/* Symmetrical sigmoid function. */
return (SigmoidPrimeOffset + (0.25 - value*value));
case ASYMSIGMOID:
/* asymmetrical sigmoid function in range 0.0 to 1.0. */
return (SigmoidPrimeOffset + (value * (1.0 - value)));
}
}
/*
* Compute the error for one output unit.
* HyperErr==0 => use squared error.
* HyperErr==1 => use atanh.
*/
float ERRFUN (desired, actual)
float desired, actual;
{
float dif;
dif = desired - actual;
if ( KeepScore )
{
TotalError += dif*dif;
if ( fabs(dif) >= ScoreThreshold )
TotalErrorBits++;
}
if ( HyperErr == 0 ) /* Not using atanh for error */
{
if ((-0.1 < dif) && (dif < 0.1))
return (0.0);
else
return (dif);
}
else /* Using atanh for error */
{
if ( dif < -.9999999 )
return (-17.0);
else if ( dif > .9999999 )
return (17.0);
else
return ( log ( (1.0+dif) / (1.0-dif) ) );
}
}
/*
* This is it, ya Habaayib: the forward pass in BP.
*/
FORWARD_PASS (input)
float input[];
{
int i, j;
float sum;
/* Load in the input vector */
for (i=0; i<Ninputs; i++)
Outputs[i+1] = input[i];
/* For each unit, collect incoming activation and pass through sigmoid. */
for (j=FirstHidden; j<Nunits; j++)
{
sum = 0.0;
for (i=0; i<Nconnections[j]; i++)
sum += ( Outputs[ Connections[j][i] ] * Weights[j][i] );
Outputs[j] = ACTIVATION(sum);
}
}
/*
* Goal is a vector of desired values for the output units. Propagate
* the error back through the net, accumulating weight deltas.
*/
BACKWARD_PASS (goal)
float goal[];
{
int i, j, cix; /* cix is "connection index" */
/* Compute error sums for output and other nodes */
for (i=FirstOutput; i<Nunits; i++) /* !! should it really be "<"? */
ErrorSums[i] = ERRFUN( goal[i-FirstOutput], Outputs[i]);
for (i=0; i<FirstOutput; i++)
ErrorSums[i] = 0.0;
/* Back-prop. When we reach a given unit in loop, error from all later
* units will have been collected.
*/
for (j=Nunits-1; j>=FirstHidden; j--)
{
Errors[j] = ACTIVATION_PRIME(Outputs[j]) * ErrorSums[j];
for (i=0; i<Nconnections[j]; i++)
{
cix = Connections[j][i];
ErrorSums[cix] += ( Errors[j] * Weights[j][i] );
Slopes[j][i] += ( Errors[j] * Outputs[cix] );
}
}
}
/*
* Update all weights in the network as a function of each weight's current
* slope, previous slope, and the size of the last jump.
*/
UPDATE_WEIGHTS()
{
int i, j;
float next_step, shrink_factor;
shrink_factor = MaxFactor / ( 1.0 + MaxFactor );
for (j=FirstHidden; j<Nunits; j++)
for (i=0; i<Nconnections[j]; i++)
{
next_step = 0.0;
if ( DeltaWeights[j][i] > ModeSwitchThreshold )
{ /* Last step was signif. +ive..... */
if ( Slopes[j][i] > 0.0 ) /* Add in epsilon if +ive slope */
next_step += (SplitEpsilon ?
( (Epsilon * Slopes[j][i]) / Nconnections[j] ) :
( Epsilon * Slopes[j][i] ));
/* If slope > (or close to) prev slope, take max size step. */
if ( Slopes[j][i] > (shrink_factor * PrevSlopes[j][i]) )
next_step += ( MaxFactor * DeltaWeights[j][i] );
else /* Use quadratic estimate */
next_step += ( (Slopes[j][i]/(PrevSlopes[j][i]-Slopes[j][i]))
* DeltaWeights[j][i] );
}
else if ( DeltaWeights[j][i] < -ModeSwitchThreshold )
{ /* Last step was signif. -ive.... */
if ( Slopes[j][i] < 0.0 )/* Add in epsilon if -ive slope */
next_step += (SplitEpsilon ?
( (Epsilon * Slopes[j][i]) / Nconnections[j] ) :
( Epsilon * Slopes[j][i] ));
/* If slope < (or close to) prev slope, take max size step. */
if ( Slopes[j][i] < (shrink_factor * PrevSlopes[j][i]) )
next_step += ( MaxFactor * DeltaWeights[j][i] );
else /* Use quadratic estimate */
next_step += ( (Slopes[j][i]/(PrevSlopes[j][i]-Slopes[j][i]))
* DeltaWeights[j][i] );
}
else /* Normal gradient descent, complete with momentum */
{
DidGradient++;
next_step += ((SplitEpsilon ?
( (Epsilon * Slopes[j][i]) / Nconnections[j] ) :
( Epsilon * Slopes[j][i] ))
+ (Momentum * DeltaWeights[j][i]) );
}
/* Set delta weight, and adjust the weight itself. */
DeltaWeights[j][i] = next_step;
Weights[j][i] += next_step;
}
}
/*
* Perform forward and back propagation once for each pattern in the
* training set, collecting deltas. Then burn in the weights.
*/
TRAIN_ONE_EPOCH()
{
int i;
CLEAR_SLOPES();
for (i=0; i<NTrainingPatterns; i++)
{
FORWARD_PASS ( TrainingInputs[i] );
BACKWARD_PASS ( TrainingOutputs[i] );
}
UPDATE_WEIGHTS();
Epoch++;
}
/*
* Train the network for the specified number of epochs, printing out
* performance stats every 10 epochs.
*/
TRAIN ( times )
int times;
{
int i, report;
report = 50;
for (i=0; i<times; i++)
{
if ( Epoch % report == 0 ) /* Time to report status */
{
DidGradient = 0;
KeepScore = 1;
TotalError = 0.0;
TotalErrorBits = 0;
TRAIN_ONE_EPOCH();
printf ("Epoch %d: %d Bits Wrong, Total Error = %f, DidGradient = %d.\n",
(Epoch - 1), TotalErrorBits, TotalError, DidGradient);
KeepScore = 0;
}
else
TRAIN_ONE_EPOCH();
}
}
TEST ()
{
int i,j;
tinputs[0] = 1.0; /* Initial nonzero value */
while (tinputs[0] >= 0.0)
{
/* printf ("Enter the %d input values [first one less than 0.0 => quit]: ",
Ninputs);
for (i=0; i<Ninputs; i++)
scanf ("%f", &tinputs[i]);
*/
for(j=0; j<NTestPatterns; j++){
for (i=0; i<Ninputs; i++)
tinputs[i] = TestInputs[j][i];
FORWARD_PASS(tinputs);
printf ("Output for test pattern %d is: ",j);
for (i=0; i<Noutputs; i++)
printf ("%f ", Outputs[FirstOutput+i]);
printf ("\n");
}
tinputs[0] = -0.5;
}
}
/*--------------------- cut here ----------------------------------------*/
/* 3 example net files follow. 2 versions of XOR and one larger problem */
/*-------------- This is an example network with shortcut connections --*/
/* This is network of 2=2=1 architecture with links between the input layer
** and the output layer. In this case the output node receives input from
** all other nodes in the network.
**
** The third line specifies the unit type. Possible unit types are:
** 1 for SIGMOIDAL and 2 for ASYMSIGMOIDAL.
*/
/*------------ End of comment ---------------------------------------*/
/* Network specification begins from the line below the current one. */
#ifdef YOU_WANT_TO_COMPILE_JUNK
XOR with 1 hidden unit and crosscut connections.
1st Connect call connects inputs to both hidden and output, 2nd call connects
hidden unit to the output unit.
#
/* start of net
Ninputs 2 Nhidden 1 Noutputs 1
UnitType 1
Connectcalls 2
1 2 3 4
3 3 4 4
NTrainingPatterns 4
0.0 0.0 -0.5
0.0 1.0 0.5
1.0 0.0 0.5
1.0 1.0 -0.5
NTestPatterns 4
0.0 0.0 -0.5
0.0 1.0 0.5
1.0 0.0 0.5
1.0 1.0 -0.5
end of first example */
/*-------------- This is an example network with shortcut connections --*/
/* This is network of 2=2=1 architecture with links between the input layer
** and the output layer. In this case the output node receives input from
** all other nodes in the network.
**
** The third line specifies the unit type. Possible unit types are:
** 1 for SIGMOIDAL and 2 for ASYMSIGMOIDAL.
*/
/*------------ End of comment ---------------------------------------*/
/* Network specification begins from the line below the current one. */
XOR with 2 hidden units and no crosscut connections.
1st Connect call connects inputs to both hidden and output, 2nd call connects
hidden unit to the output unit.
#
/* start of net
Ninputs 2 Nhidden 2 Noutputs 1
UnitType 1
Connectcalls 2
1 2 3 4
3 4 5 5
NTrainingPatterns 4
0.0 0.0 -0.5
0.0 1.0 0.5
1.0 0.0 0.5
1.0 1.0 -0.5
NTestPatterns 4
0.0 0.0 -0.5
0.0 1.0 0.5
1.0 0.0 0.5
1.0 1.0 -0.5
end of second example */
/*
This is a sample input network. All characters before the pound sign
below are ignored.
#
Ninputs 4 Nhidden 6 Noutputs 1
UnitType 2
Connectcalls 2
1 4 5 10
5 10 11 11
NTrainingPatterns 36
0.33 0.33 0.33 0.33 1.0
0.67 0.33 0.33 0.33 0.0
1.00 0.33 0.33 0.33 0.0
0.33 0.33 0.67 0.33 0.0
0.67 0.33 0.67 0.33 1.0
1.00 0.33 0.67 0.33 0.0
0.33 0.33 1.00 0.33 0.0
0.67 0.33 1.00 0.33 0.0
1.00 0.33 1.00 0.33 1.0
0.33 0.33 0.33 0.67 1.0
0.67 0.33 0.33 0.67 1.0
1.00 0.33 0.33 0.67 0.0
0.33 0.33 0.67 0.67 0.0
0.67 0.33 0.67 0.67 1.0
1.00 0.33 0.67 0.67 1.0
0.33 0.33 0.33 1.00 1.0
0.67 0.33 0.33 1.00 1.0
1.00 0.33 0.33 1.00 1.0
0.33 0.67 0.33 0.33 0.0
0.67 0.67 0.33 0.33 0.0
0.33 0.67 0.67 0.33 0.0
0.67 0.67 0.67 0.33 0.0
0.33 0.67 1.00 0.33 0.0
0.67 0.67 1.00 0.33 0.0
0.33 0.67 0.33 0.67 1.0
0.67 0.67 0.33 0.67 0.0
0.33 0.67 0.67 0.67 0.0
0.67 0.67 0.67 0.67 1.0
0.33 0.67 0.33 1.00 1.0
0.67 0.67 0.33 1.00 1.0
0.33 1.00 0.33 0.33 0.0
0.33 1.00 0.67 0.33 0.0
0.33 1.00 1.00 0.33 0.0
0.33 1.00 0.33 0.67 0.0
0.33 1.00 0.67 0.67 0.0
0.33 1.00 0.33 1.00 1.0
NTestPatterns 0
end of last example */
#endif /* YOU_WANT_TO_COMPILE_JUNK */
/* end of quickprop1.c */