public double[] ReturnedError(Neuron []Y,int index) { double[] error = new double[OutPutLayerSize]; for (int j = 0; j < OutPutLayerSize; j++) { error[j] = outPuts[index][j] - Y[j].OutPutValue; } return error; }
public void GetInputpublic(byte[,] buffer, int RowSize, int ColSize, Neuron[] InputLayer, int outputlayersize = 0, int NoOfIteration = 0, double LearningRate = 0.1) { int Count = 0; for (int j = 0; j < RowSize; j++) { for (int i = 0; i < ColSize; i++) { InputLayer[Count++].NetInput = Convert.ToDouble(buffer[j, i]); } } }
public void GetInputpublic(byte[,] buffer, int RowSize, int ColSize, Neuron[] InputLayer, int outputlayersize = 0, int NoOfIteration = 0, double LearningRate = 0.1) { Neuron[] PCAoutPutLayer = new Neuron[outputlayersize]; PCA P = new PCA(InputLayer.Length, outputlayersize, LearningRate); P.GetInput(buffer,RowSize,ColSize); P.Run(NoOfIteration); PCAoutPutLayer = P.Show(); for(int j=0;j<outputlayersize;j++) { InputLayer[j].NetInput = PCAoutPutLayer[j].OutPutValue; } }
public PCA(int inputLayerSize, int OutPutLayerSize, double LearningRate) { this.InputLayerSize = inputLayerSize; this.OutPutLayerSize = OutPutLayerSize; this.LearningRate = LearningRate; InputLayer = new Neuron[inputLayerSize]; OutPutLayer = new Neuron[OutPutLayerSize]; for (int j = 0; j < inputLayerSize; j++) { InputLayer[j] = new Neuron(OutPutLayerSize); } for (int j = 0; j < OutPutLayerSize; j++) { OutPutLayer[j] = new Neuron(); } }
public InputStyle IS;// define the way you get input from PCA or from Images ! public NetWork(int InputLayerSize, int OutPutLayerSize, int[] HiddenLayersSize, double LearningRate,InputStyle IS) { // Construction of network ! input Layers ! Hidden Layers ! output Layers this.IS = IS; Target = new Desired(OutPutLayerSize); this.LearningRate = LearningRate; Target.Creat();// Create Desired output for each class; NoOfHiddenLayers = HiddenLayersSize.Length; InputLayer = new Neuron[InputLayerSize]; OutputLayer = new Neuron[OutPutLayerSize]; HiddenLayers = new Neuron[NoOfHiddenLayers][]; // intilize Size of hidden layers; for (int j = 0; j < NoOfHiddenLayers; j++) { HiddenLayers[j] = new Neuron[HiddenLayersSize[j]]; } // initlize Input Layer With Objects To be Trained; for (int j = 0; j < InputLayerSize; j++) { InputLayer[j] = new Neuron(HiddenLayers[0].Length); } // initlize outPut Layer with objects; for (int j = 0; j < OutPutLayerSize; j++) { OutputLayer[j] = new Neuron(); } // intilize Hidden layers with objects except last one because it depends on outputlayer; for (int j = 0; j < NoOfHiddenLayers - 1; j++) { for (int i = 0; i < HiddenLayersSize[j]; i++) { HiddenLayers[j][i] = new Neuron(HiddenLayersSize[j + 1]); } } // intilize last Layer in network with objects for (int j = 0; j < HiddenLayersSize[NoOfHiddenLayers - 1]; j++) { HiddenLayers[NoOfHiddenLayers - 1][j] = new Neuron(OutPutLayerSize); } }