diff --git a/include/NeuralNetwork/ConstructiveAlgorithms/CascadeCorrelation.h b/include/NeuralNetwork/ConstructiveAlgorithms/CascadeCorrelation.h index 6820947..942ba1a 100644 --- a/include/NeuralNetwork/ConstructiveAlgorithms/CascadeCorrelation.h +++ b/include/NeuralNetwork/ConstructiveAlgorithms/CascadeCorrelation.h @@ -39,7 +39,7 @@ namespace NeuralNetwork { } else { error = trainOutputs(network, patterns); } - while(_epoch++ < _maxEpochs && _neurons++ < _maxHiddenUnits && error > _errorTreshold) { + while(_epoch++ < _maxEpochs && _neurons < _maxHiddenUnits && error > _errorTreshold) { std::vector> candidates = createCandidates(network.getNeuronSize() - outputs); std::pair, std::vector> candidate = trainCandidates(network, candidates, patterns); diff --git a/src/NeuralNetwork/ConstructiveAlgorithms/Cascade2.cpp b/src/NeuralNetwork/ConstructiveAlgorithms/Cascade2.cpp index df62f07..90b91ac 100644 --- a/src/NeuralNetwork/ConstructiveAlgorithms/Cascade2.cpp +++ b/src/NeuralNetwork/ConstructiveAlgorithms/Cascade2.cpp @@ -66,8 +66,6 @@ std::pair, std::vector> Cascade2:: float weight = candidateWeights[candidateIndex][output]; float diff = activationValue * weight - errors[patternIndex][output]; - float goalDir= pattern.second[output] <0.0? -1.0 :1.0; - float diffDir= diff >0.0? -1.0 :1.0; score -= (diff * diff); outSlopes[output] -= 2.0 * diff * activationValue; errSum += diff * weight; diff --git a/src/NeuralNetwork/ConstructiveAlgorithms/CascadeCorrelation.cpp b/src/NeuralNetwork/ConstructiveAlgorithms/CascadeCorrelation.cpp index 66661a6..f05de73 100644 --- a/src/NeuralNetwork/ConstructiveAlgorithms/CascadeCorrelation.cpp +++ b/src/NeuralNetwork/ConstructiveAlgorithms/CascadeCorrelation.cpp @@ -190,6 +190,10 @@ std::pair , std::vector> CascadeCo } } + if(sumSquareError < 0.01) { + sumSquareError=0.01; + } + std::for_each(meanErrors.begin(), meanErrors.end(), [&patterns](float &n) { n /= patterns.size(); }); struct CAND {