/*--------------------------------------------------------------------------------------------
* Neural Network Prototype
*
* Perceptron Learning (See Russell & Norvig PP 742)
*
* Terry 10 Nov. 2004
*------------------------------------------------------------------------------------------*/
#include <iostream>
#include <fstream>
#include <string>
#include <math.h>
//#include < cmath >
//#include <conio.h>
#include <time.h>
#include <stdlib.h>
using namespace std;
////////////////////////////////////////////////////////////////////////////////
class NeuralNet {
public:
int RULE;
double UPPERBOUND;
double LOWERBOUND;
static const int NUM_INPUT = 10;
static const int NUM_HIDDEN = 6;
static const int NUM_OUTPUT = 2;
static const int NUM_PATTERNS=200;
int xp[NUM_PATTERNS][NUM_INPUT];
double yp[NUM_PATTERNS][NUM_OUTPUT];
static const int NUM_DATA = 1000;
int xt[NUM_DATA][NUM_INPUT ];
double yt[NUM_DATA][NUM_OUTPUT];
double weights1[NUM_HIDDEN][NUM_INPUT+1];
double weights2[NUM_OUTPUT][NUM_HIDDEN+1];
static const double alpha = 0.1; // learning rate
bool fullytrained;
////////////////////////////////////////////////////////////////////////////////
NeuralNet(){
UPPERBOUND=1;
LOWERBOUND=0;
RULE = 6;
srand( 100);
for(int j=0;j<NUM_HIDDEN;j++) {
weights1[j][0] = 0.0;
for (int k =1; k<=NUM_INPUT; k++){
weights1[j][k] = (double)(rand()%1000)/2000 - 0.25; // set up starting weights - eg all random
// cout <<" w1["<< k <<"]["<< j << "]:" <<weights1[k][j]<<endl;
}
// cout <<endl;
}
for(int i=0;i<NUM_OUTPUT;i++) {
weights2[i][0] = 0.0;
for (int j =0; j<=NUM_HIDDEN; j++){
weights2[i][j] = (double)(rand()%1000)/2000 - 0.25; // set up starting weights - eg all random
// cout <<" w2["<< j <<"]["<< i << "]:" <<weights2[j][i]<<endl;
}
// cout <<endl;
}