NNffbpAlphaTabFast { public NNCalc calcJacobi(double[] nnInp) { final NNCalc res = NNresjacob; for (int i = 0; i < nn_in; i++) { act[0][i] = (nnInp[i] - inmin[i]) / (inmax[i] - inmin[i]); } for (int pl = 0; pl < nplanes - 1; pl++) { final double[] act_pl_1 = act[pl + 1]; final double[] help_pl = help[pl]; final double[][] wgt_pl = wgt[pl]; final double[] bias_pl = bias[pl]; final double[] act_pl = act[pl]; for (int i = 0; i < size[pl + 1]; i++) { act_pl_1[i] = activation(bias_pl[i] + scp(wgt_pl[i], act_pl)); help_pl[i] = act_pl_1[i] * (1.0 - act_pl_1[i]); } final double[][] dActDX_pl = dActDX[pl]; final double[][] dActDX_pl1 = dActDX[pl + 1]; for (int i = 0; i < size[pl + 1]; i++) { for (int j = 0; j < nn_in; j++) { double sum = 0.0; final double help_pl_i = help_pl[i]; final double[] wgt_pl_i = wgt_pl[i]; for (int k = 0; k < size[pl]; k++) { sum += help_pl_i * wgt_pl_i[k] * dActDX_pl[k][j]; } dActDX_pl1[i][j] = sum; } } } final double[] act_nplanes_1 = act[nplanes - 1]; final double[][] dActDX_nplanes_1 = dActDX[nplanes - 1]; final double[][] jacobiMatrix = res.getJacobiMatrix(); final double[] nnOutput = res.getNnOutput(); for (int i = 0; i < nn_out; i++) { final double diff = outmax[i] - outmin[i]; nnOutput[i] = act_nplanes_1[i] * diff + outmin[i]; final double[] res_jacobiMatrix_i = jacobiMatrix[i]; final double[] dActDX_nplanes_1_i = dActDX_nplanes_1[i]; for (int k = 0; k < nn_in; k++) { res_jacobiMatrix_i[k] = dActDX_nplanes_1_i[k] * diff; } } return res; } NNffbpAlphaTabFast(String neuralNet);  NNffbpAlphaTabFast(InputStream neuralNetStream); double[] getInmin(); void setInmin(double[] inmin); double[] getInmax(); void setInmax(double[] inmax); double[] getOutmin(); double[] getOutmax(); NNCalc calcJacobi(double[] nnInp); double[] calc(double[] nninp);  }
@Test public void testCalcJacobi() { final NNffbpAlphaTabFast tab = loadTestNet(); final double[] nnInput = new double[]{1.0, 3.4, 6.988, 4.4, 7.0, 16.21}; final NNCalc nnCalc = tab.calcJacobi(nnInput); final double[] expNnOutput = new double[]{0.9999546066706964}; assertEquals(expNnOutput[0], nnCalc.getNnOutput()[0], 1.0e-6); final double[][] expJacobiMatrix = new double[][]{ { -7.3325278006568306E-6, 3.2639459486171825E-6, 7.527711538784537E-6, -8.186466522910375E-6, 9.557482758745628E-6, 1.2507178214659703E-5 } }; final double[][] jacobiMatrix = nnCalc.getJacobiMatrix(); for (int i = 0; i < jacobiMatrix.length; i++) { for (int j = 0; j < jacobiMatrix[i].length; j++) { assertEquals(expJacobiMatrix[i][j], jacobiMatrix[i][j], 1.0e-6); } } }