/// <summary> /// Uses the network with one input pattern to genereate output. /// </summary> /// <param name="pat">input pattern. Size (PatternSize X 1)</param> /// <returns>the output matrix of the network</returns> internal Matrix <float> use(ArrayInputData pat) { // convert pat.Key = pat.Key.InsertRow(pat.Key.RowCount, new DenseVector(1, 1.0f)); // pass forwardPass(pat.Key); // return result return(net_out); }
/// <summary> /// Trains the network using common backprop. /// </summary> /// <param name="traindata">all training data used in this training session. Matrix must have the size (PatternSize X PatternCount)</param> /// <param name="epochs">Number of epochs to train the network.</param> internal void backpropTraining(ArrayInputData traindata, int epochs) { // training pattern init Matrix <float> pat = new DenseMatrix(traindata.Key.RowCount + 1, traindata.Key.ColumnCount, 1.0f); pat.SetSubMatrix(0, traindata.Key.RowCount, 0, traindata.Key.ColumnCount, traindata.Key); // target values init Matrix <float> targets = traindata.Value; // dw, dv Matrix <float> dw = new DenseMatrix(HiddenNodes, PatternSize + 1); Matrix <float> dv = new DenseMatrix(TargetSize, HiddenNodes + 1); // training for (int i = 0; i < epochs; i++) { // backprop forwardPass(pat); backwardPass(pat, targets); weightUpdate(pat, dw, dv, targets); } }