diff --git a/include/NeuralNetwork/ConstructiveAlgorithms/CascadeCorrelation.h b/include/NeuralNetwork/ConstructiveAlgorithms/CascadeCorrelation.h index c3daf1c..278ea31 100644 --- a/include/NeuralNetwork/ConstructiveAlgorithms/CascadeCorrelation.h +++ b/include/NeuralNetwork/ConstructiveAlgorithms/CascadeCorrelation.h @@ -52,6 +52,8 @@ namespace NeuralNetwork { error = trainOutputs(network, patterns); } + std::cout << error << "\n"; + if(_prunningStatus && error*1.01 >= lastError) { // it is not getting bettter network.removeLastHiddenNeuron(); error=lastError; diff --git a/include/NeuralNetwork/ProblemSets/Parity.h b/include/NeuralNetwork/ProblemSets/Parity.h index fe6c106..9965ed5 100644 --- a/include/NeuralNetwork/ProblemSets/Parity.h +++ b/include/NeuralNetwork/ProblemSets/Parity.h @@ -6,15 +6,15 @@ namespace NeuralNetwork { namespace ProblemSets { typedef std::pair, std::vector> TrainingPattern; - std::vector Parity3() { + std::vector Parity3(float min = 0.0) { return { - {{0,0,0},{0}}, - {{0,0,1},{1}}, - {{0,1,0},{1}}, - {{0,1,1},{0}}, - {{1,0,0},{1}}, - {{1,0,1},{0}}, - {{1,1,0},{0}}, + {{min,min,min},{min}}, + {{min,min,1},{1}}, + {{min,1,min},{1}}, + {{min,1,1},{min}}, + {{1,min,min},{1}}, + {{1,min,1},{min}}, + {{1,1,min},{min}}, {{1,1,1},{1}}, }; } diff --git a/src/NeuralNetwork/ConstructiveAlgorithms/CascadeCorrelation.cpp b/src/NeuralNetwork/ConstructiveAlgorithms/CascadeCorrelation.cpp index 87587dc..66661a6 100644 --- a/src/NeuralNetwork/ConstructiveAlgorithms/CascadeCorrelation.cpp +++ b/src/NeuralNetwork/ConstructiveAlgorithms/CascadeCorrelation.cpp @@ -48,7 +48,8 @@ float CascadeCorrelation::trainOutputs(Cascade::Network &network, const std::vec } while(iteration++ < _maxOutputLearningIterations && iterWithoutImporvement < _maxOutputLearningIterationsWithoutChange); - std::cout << "outputLearning: " << error << ", last: " << lastError << ", iters: " << iteration << "\n"; +// std::cout << "outputLearning: " << error << ", last: " << lastError << ", iters: " << iteration << "\n"; + for(std::size_t neuron = 0; neuron < outputs; neuron++) { network.getOutputNeurons()[neuron]->setWeights(p[1][neuron + 1].getWeights()); } @@ -144,7 +145,7 @@ float CascadeCorrelation::trainOutputsRandom(std::size_t step, Cascade::Network FeedForward::Network &p = *possibleOutputs[bestNetwork]; - std::cout << "network: " << bestNetwork << ", error: " << bestScore << "\n"; + std::cout << "network: " << bestNetwork << "\n"; for(std::size_t neuron = 0; neuron < outputs; neuron++) { network.getNeuron(network.getNeuronSize() - outputs + neuron)->setWeights(p[1][neuron + 1].getWeights());