; }
~NeuralNet(){}
////////////////////////////////////////////////////////////////////////////////
void PrintWeights(){
for(int j=0;j<NUM_HIDDEN;j++) {
for (int k =0; k<=NUM_INPUT; k++){
cout <<" w1["<< j <<"]["<< k << "]:" <<weights1[j][k]<<endl;}
cout <<endl;}
for(int i=0;i<NUM_OUTPUT;i++) {
for (int j =0; j<=NUM_HIDDEN; j++){
cout <<" w2["<< i <<"]["<< j << "]:" <<weights2[i][j]<<endl;}
cout <<endl;}
}
////////////////////////////////////////////////////////////////////////////////
double CalInput2Hidden(int j, int vct[NUM_INPUT]){
double in_to_hidden = 0.0;
in_to_hidden+=(-1.0) * weights1[j][0];
for(int k=1;k<=NUM_INPUT;k++)
{in_to_hidden += weights1[j][k] * vct[k-1];}
return in_to_hidden;
}
double CalInput2Output(int i, double vct[NUM_HIDDEN]){
double in_to_output = 0.0;
in_to_output+=(-1.0) * weights2[i][0];
for(int j=1;j<=NUM_HIDDEN;j++)
{in_to_output += weights2[i][j] * vct[j-1];}
return in_to_output;
}
////////////////////////////////////////////////////////////////////////////////
double sigmoid( double x ){ return 1.0 /( 1.0 + exp( - x ) ); } // g
double derivative( double x ){ // the derivative of the sigmoid function g'
double sig = sigmoid(x);
return sig * ( 1.0 - sig );}
////////////////////////////////////////////////////////////////////////////////
string FormattedOutput(double input[NUM_OUTPUT]){
if (input[0] > input[1])
return "10";
else
return "01";
}
///////////////////////////////////////////////////////
void CreateTestData(){
cout <<"Generating " << NUM_DATA<< " random testing data ...";
for(int p=0; p<NUM_DATA; p++){
// for(int p=NUM_PATTERNS; p<NUM_DATA; p++){
int sum=0;
// create inputs x[j] an