public void Train(NeuralNetworkTrainArgs trainArgs) { TrainArgs = trainArgs; for (int epoch = 0; epoch < trainArgs.trainEpoches; ++epoch) { trainArgs.onOnceEpoch?.Invoke(epoch); for (int i = 0; i < trainArgs.trainingData.Length; ++i) { TrainOnce(trainArgs.trainingData[i], trainArgs.trainingLabels[i], trainArgs.learningRate); } } trainArgs.onOnceEpoch?.Invoke(trainArgs.trainEpoches); trainArgs.onFinish?.Invoke(); }
public void CheckGradient(NeuralNetworkTrainArgs trainArgs) { TrainArgs = trainArgs; var input = trainArgs.trainingData[0]; var label = trainArgs.trainingLabels[0]; var predict = Forward(input); var delta = predict - label; var temp = delta; for (int i = _layers.Count - 1; i >= 0; --i) { var layer = _layers[i]; temp = layer.CheckGradient(temp); } }