예제 #1
0
 private void BackpropagationCalculation(int j) {
   errorOutput = (idealOutput - actualOutput) * SupportFunction.derivativesigmoid(actualOutput);
   for (int i = 0; i < matrix_weight_delta_HiddenOutput.getRows(); i++) {
     matrix_weight_delta_HiddenOutput.set(
         i, 0, argLearningRate * errorOutput * matrix_HiddenLayerOutputSignal.get(0, i));
   }
   for (int i = 1; i < matrix_weight_HiddenOutput.getRows(); i++) {
     errorHidden =
         (errorOutput * matrix_weight_HiddenOutput.get(i, 0))
             * SupportFunction.derivativesigmoid(matrix_HiddenLayerOutputSignal.get(0, i));
     for (int k = 0; k < matrix_weight_delta_InputHidden.getRows(); k++) {
       matrix_weight_delta_InputHidden.set(
           k, i - 1, argLearningRate * errorHidden * matrix_InputLayerInputSignal.get(0, k));
     }
   }
 }
예제 #2
0
 private void FeedForwardCalculation(int j) {
   // [0,0] add a bias at the front [1,0,0]
   matrix_InputLayerInputSignal = SupportFunction.createInputMatrix(inputPatterns[j]);
   // input multiply with weight matrix
   matrix_HiddenLayerInputSignal =
       MatrixMath.multiply(matrix_InputLayerInputSignal, martix_weight_InputHidden);
   // pass the Hidden Layers input through the activation function and add
   // a bias at first
   for (int i = 0; i < matrix_HiddenLayerInputSignal.getCols(); i++) {
     matrix_HiddenLayerOutputSignal.set(
         0, i + 1, SupportFunction.sigmoid(matrix_HiddenLayerInputSignal.get(0, i)));
     matrix_HiddenLayerOutputSignal.set(0, 0, 1); // add bias at the
     // front
   }
   // get output result
   matrix_OutputLayerInputSignal =
       MatrixMath.multiply(matrix_HiddenLayerOutputSignal, matrix_weight_HiddenOutput);
   // pass the output result through a activation function
   actualOutput = SupportFunction.sigmoid(matrix_OutputLayerInputSignal.get(0, 0));
 }