예제 #1
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));
 }
예제 #2
0
 private void weightMatrixUpdate() {
   martix_weight_InputHidden =
       MatrixMath.add(
           martix_weight_InputHidden,
           MatrixMath.multiply(matrix_weight_privious_delta_InputHidden, argMomentum));
   martix_weight_InputHidden =
       MatrixMath.add(martix_weight_InputHidden, matrix_weight_delta_InputHidden);
   matrix_weight_HiddenOutput =
       MatrixMath.add(
           matrix_weight_HiddenOutput,
           MatrixMath.multiply(matrix_weight_privious_delta_HiddenOutput, argMomentum));
   matrix_weight_HiddenOutput =
       MatrixMath.add(matrix_weight_HiddenOutput, matrix_weight_delta_HiddenOutput);
   matrix_weight_privious_delta_InputHidden =
       MatrixMath.add(
           matrix_weight_delta_InputHidden,
           MatrixMath.multiply(matrix_weight_privious_delta_InputHidden, argMomentum));
   matrix_weight_privious_delta_HiddenOutput =
       MatrixMath.add(
           matrix_weight_delta_HiddenOutput,
           MatrixMath.multiply(matrix_weight_privious_delta_HiddenOutput, argMomentum));
 }