Example #1
0
 public void CalculateDiagonalHessian(INNInputProvider PProvider, int PHessianBatchLength)
 {
     double[][] input   = new double[PHessianBatchLength][];
     double[][] desired = new double[PHessianBatchLength][];
     for (int i = 0; i < PHessianBatchLength; i++)
     {
         input[i]   = PProvider.NextInputCase();
         desired[i] = PProvider.DesiredOutput();
     }
     double[][][] output = GetOutputFromInputsBatch(input);
     diagonalhessian = GetDerivativesFromOutputBatch(TDerivative.Second, output, input, desired);
     PProvider.Rewind(PHessianBatchLength);
 }
Example #2
0
 public override void Train(INNInputProvider PProvider)
 {
     double[]     input       = PProvider.NextInputCase();
     double[][]   output      = GetOutputFromInputs(input);
     double[][][] derivatives = GetDerivativesFromOutput(TDerivative.First, output, input, PProvider.DesiredOutput());
     for (int i = 0; i < numlayers; i++)
     {
         for (int j = 0; j < layers[i].NumNeurons; j++)
         {
             int numweightsback = weights[i][j].GetLength(0);
             for (int k = 0; k < numweightsback; k++)
             {
                 derivatives[i][j][k] *= (-learnrates[i]) / (diagonalhessian[i][j][k] + blowuppreventer);
             }
             derivatives[i][j][numweightsback] *= (-learnrates[i]) / (diagonalhessian[i][j][numweightsback] + blowuppreventer);
         }
     }
     ModifyWeights(derivatives);
 }