using System; namespace Neural_Networks { /// /// Summary description for Nnetwork. /// public class Nnetwork { private int i; private int o; private int h; private double LH=0.15f; // learning parameter of the hidden private double LO=0.2f; // learning parameter of the output private double []inputsToNetwork;// array of double to take training data "inputs" private double []desiredOutputs;// array of double to take training data "desired outputs" private node []input; // array of input neurons private node []output;// array of output neurons private node []hidden;// array of hidden units neurons private double total_error; public double error_compared_to_tolerance=0; /// /// this function to calculate the sigmoid of a double /// /// double number /// private double sigmoid(double x) { return 1/(1+Math.Exp(-x)); } #region these functions must be called before callind training /// /// Constructor of the neural network /// /// integer : number of input neurons /// integer : number of hidden units neurons /// integer : number of output neurons public Nnetwork(int inp , int hide , int outp ) { i = inp ; o = outp ; h = hide; int ahm = 0; input = new node[i]; output = new node[o]; hidden = new node[h]; Random rand = new Random(unchecked((int)DateTime.Now.Ticks)); // initialize the network arrays and the weights for(int x=0 ; x /// This function to set the threshold of the neruons in the hidden layer and the output layer /// public void FirstTimeSettings() { Random x = new Random(unchecked((int)DateTime.Now.Ticks)); for(int i=0 ; i /// This function passes training data to the network , inputs and desired ouptus /// /// public void BeforeTraining(params double []list) { int counter=0; int j=0; int k=0; inputsToNetwork = new double[this.i]; desiredOutputs = new double[this.o]; while(counter < list.Length) { if( counter < this.i) { inputsToNetwork[j] = list [counter]; j++; } else { desiredOutputs[k] = list[counter]; k++; } counter++; } } #endregion /// /// a function to calculate the activation of the hidden layer and the output layer /// private void Calc_Activation() { // a loop to set the activations of the hidden layer int ch=0; while(ch