1 #ifndef BATCHBACKPROPAGATIONALGORITHM_H
2 #define BATCHBACKPROPAGATIONALGORITHM_H
4 #include "NeuralNetConfig.h"
7 #include "NeuralNetDataSet.h"
12 #include "InputNormaliser.h"
17 class InputNormaliser;
34 void setLearningRate(
const double newLearningRate)
35 { _learningRate = newLearningRate;}
36 void setMomentumConstant(
const double newMomentumConstant)
37 { _momentumConstant = newMomentumConstant;}
38 void setMaxErrorIncrease(
const double maxIncrease)
39 { _maxErrorInc = maxIncrease;}
41 const NeuralNet::InputNormalisationSelect normaliseTrainingData=NeuralNet::PassthroughNormalised);
42 double train(
const int numberOfEpochs,
const NeuralNetDataSet &dataSet,
const std::vector<InputNormaliser *> &inputNormalisers);
43 void setProgressPrintoutFrequency(
const int frequency) {_progressPrintoutFrequency = frequency;}
44 void setEpochsToWaitBeforeRestore(
const int epochs) {_epochsToWaitBeforeRestore = epochs;}
45 std::vector<double> getTrainingErrorValuesPerEpoch()
const {
return _savedEpochErrorValues;}
48 double trainWithDataSet(
const int numberOfEpochs);
49 std::vector<double> layerOutput(
const int layer)
const;
50 void calculateLayerOutputs();
51 void calculateDerivativeOutputs();
52 void calculateErrorSignals();
53 void calculateRunningGradientTotal();
54 void calculateDeltaWeights();
57 double processDataSet();
60 typedef std::vector<std::vector<double> > NetMatrix;
66 const std::vector<double> *_inputs,*_target;
67 NetMatrix _neuronErrorSignals;
68 NetMatrix _neuronOutputs;
69 NetMatrix _neuronDerivativeOutputs;
70 NetMatrix _runningGradientTotal;
71 std::vector<double> _momentumWeights;
72 std::vector<double> _previousEpochWeights;
73 double _momentumConstant;
74 int _numberOfTrainingEvents;
75 double _previousEpochError;
76 double _runningEpochErrorTotal;
78 int _progressPrintoutFrequency;
79 int _epochsToWaitBeforeRestore;
80 std::vector<double> _savedEpochErrorValues;