home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Club Amiga de Montreal - CAM
/
CAM_CD_1.iso
/
files
/
618a.lha
/
NeuralNetwork
/
xor_dbd.cc
< prev
Wrap
C/C++ Source or Header
|
1992-03-05
|
1KB
|
65 lines
#include <stdio.h>
#include <stdlib.h>
#include "Neural_network.h"
int main ()
{
int error;
Neural_network nn ("weights.xor",error,0.1,0.05,0.1,0.8,0.2,0.025);
double input [4] [2],output [4];
int done,num_wrong,skip,actual_printed;
int x,print_it,loops;
// Create inputs and desired outputs. Use XOR test.
input [0] [0] = 0.0;
input [0] [1] = 0.0;
output [0] = 0.0;
input [1] [0] = 1.0;
input [1] [1] = 0.0;
output [1] = 1.0;
input [2] [0] = 0.0;
input [2] [1] = 1.0;
output [2] = 1.0;
input [3] [0] = 1.0;
input [3] [1] = 1.0;
output [3] = 0.0;
done = 0;
print_it = 0;
loops = 0;
while ( !done )
{
if ( (loops % 50) == 0 )
{
printf ("Epoch = %d ",loops);
print_it = 2;
}
else
print_it = 0;
done = 1;
for (x = 0; x < 4; ++x)
{
nn.calc_forward (input [x],&output [x],num_wrong,skip,
print_it,actual_printed);
nn.back_propagation (input [x],&output [x],done);
}
nn.update_weights ();
if ( print_it )
printf ("\n");
++loops;
}
printf ("\nTotal # Epochs done = %d\n",loops);
for (x = 0; x < 4; ++x)
{
nn.calc_forward (input [x],&output [x],num_wrong,skip,
2,actual_printed);
}
printf ("\n");
}