cascade...

This commit is contained in:
2016-05-09 21:52:39 +02:00
parent 5a7f10ba81
commit 8ae08c4b94
2 changed files with 122 additions and 81 deletions

View File

@@ -41,7 +41,7 @@ namespace NeuralNetwork {
addBestCandidate(network, candidate);
if(_maxRandomOutputWeights) {
error = trainOutputsRandom(0, network, patterns);
error = trainOutputsRandom(_epoch, network, patterns);
} else {
error = trainOutputs(network, patterns);
}
@@ -88,7 +88,7 @@ namespace NeuralNetwork {
}
protected:
std::shared_ptr<ActivationFunction::ActivationFunction> _activFunction = std::make_shared<ActivationFunction::Sigmoid>(-4.9);
std::shared_ptr<ActivationFunction::ActivationFunction> _activFunction = std::make_shared<ActivationFunction::Sigmoid>(-0.8);
float _minimalErrorStep = 0.00005;
float _maxError;
float _weightRange;
@@ -98,9 +98,9 @@ namespace NeuralNetwork {
std::size_t _maxRandomOutputWeights = 0;
std::size_t _numberOfCandidates;
std::size_t _maxOutpuLearningIterations = 1000;
std::size_t _maxOutpuLearningIterationsWithoutChange = 5;
std::size_t _maxCandidateIterations = 20;
std::size_t _maxCandidateIterationsWithoutChange = 5;
std::size_t _maxOutpuLearningIterationsWithoutChange = 100;
std::size_t _maxCandidateIterations = 4000;
std::size_t _maxCandidateIterationsWithoutChange = 15;
std::mt19937 _generator;
std::uniform_real_distribution<> _distribution;
@@ -139,9 +139,9 @@ namespace NeuralNetwork {
for(auto &weight: weights) {
weight *= 0.9;
}
weights[weights.size() - 1] = -candidate.second[outIndex] / weightPortion;//_distribution(_generator);
outIndex++;
n->setWeights(weights);
n->weight(n->getWeights().size() - 1) = -candidate.second[outIndex] / weightPortion;
}
}
@@ -154,7 +154,7 @@ namespace NeuralNetwork {
candidates.back()->setActivationFunction(*_activFunction.get());
for(std::size_t weightIndex = 0; weightIndex < id; weightIndex++) {
candidates.back()->weight(weightIndex) = _distribution(_generator);
candidates.back()->weight(weightIndex) = _distribution(_generator) * 3.0;
}
}
return candidates;