/* * Sample program for CDA5125 * * A generic 3 level feedforward neural network from scratch * * Change N0 (input size), N1 (size of the hidden layer), * and N2 (size of the output layer) to change the neural network * * driver program train */ #include #include #include using namespace std; #define N0 2 #define N1 4 #define N2 2 double IN[N0]; double W0[N0][N1]; double B1[N1]; double HS[N1]; double HO[N1]; double W1[N1][N2]; double B2[N2]; double OS[N2]; double OO[N2]; double err; double rate = 0.1; double sigmoid(double x) { return 1/(1+exp(-x)); } // forward progagation with input: input[N0] void forward(double *input) { for (int i = 0; i