/// <summary> /// Partial convolution layer /// </summary> /// <param name="input"></param> /// <param name="isoutput"></param> public void Calculate(double[,] input, bool isoutput) { if (NN.UseNesterov && NN.UseMomentum) { for (int i = 0; i < KernelSize; i++) { for (int ii = 0; ii < KernelSize; ii++) { Weights[i, ii] = Weights[i, ii] + (NN.Momentum * WMomentum[i, ii]); } } } var output = Convolve(Weights, input); ZVals = Maths.Convert(output); if (!isoutput) { output = Maths.Tanh(output); } Values = Maths.Convert(output); }
public void Calculate(double[] input, bool output) { var vals = new double[Length]; if (NN.UseNesterov && NN.UseMomentum) { for (int i = 0; i < Length; i++) { for (int ii = 0; ii < InputLength; ii++) { Weights[i, ii] = Weights[i, ii] + (NN.Momentum * WMomentum[i, ii]); } Biases[i] = Biases[i] + (NN.Momentum * BMomentum[i]); } } for (int k = 0; k < Length; k++) { for (int j = 0; j < InputLength; j++) { vals[k] += Weights[k, j] * input[j]; } if (!output) { vals[k] += Biases[k]; } } ZVals = vals; if (!output) { Values = Maths.Tanh(vals); } else { Values = vals; } }