Cascade-Correlation ...
This commit is contained in:
@@ -38,6 +38,8 @@ float CascadeCorrelation::trainOutputs(Cascade::Network &network, const std::vec
|
||||
}
|
||||
}
|
||||
|
||||
error/=patterns.size();
|
||||
|
||||
if(fabs(lastError - error) < _minimalErrorStep) {
|
||||
iterWithoutImporvement++;
|
||||
} else {
|
||||
@@ -124,6 +126,8 @@ float CascadeCorrelation::trainOutputsRandom(std::size_t step, Cascade::Network
|
||||
}
|
||||
}
|
||||
|
||||
error/=patterns.size();
|
||||
|
||||
if(fabs(lastError - error) < _minimalErrorStep) {
|
||||
iterWithoutImporvement++;
|
||||
} else {
|
||||
@@ -237,7 +241,7 @@ std::pair <std::shared_ptr<NeuralNetwork::Neuron>, std::vector<float>> CascadeCo
|
||||
do {
|
||||
lastCorrelation = bestCorrelation;
|
||||
|
||||
/*cascor_cand_epoch*/
|
||||
/*compute correlations */
|
||||
for(std::size_t patternIndex = 0; patternIndex < patterns.size(); patternIndex++) {
|
||||
for(auto &candidateStruct : candidatesRegister) {
|
||||
auto candidate = candidateStruct.candidate;
|
||||
@@ -262,11 +266,11 @@ std::pair <std::shared_ptr<NeuralNetwork::Neuron>, std::vector<float>> CascadeCo
|
||||
}
|
||||
}
|
||||
|
||||
/*adjust ci_weights*/
|
||||
/*Update Weights*/
|
||||
for(auto &candidateStruct : candidatesRegister) {
|
||||
auto candidate = candidateStruct.candidate;
|
||||
for(std::size_t i = 0; i < candidateStruct.slopes.size(); i++) {
|
||||
candidate->weight(i) += candidateStruct.slopes[i] * 2;
|
||||
candidate->weight(i) += candidateStruct.slopes[i];
|
||||
candidateStruct.slopes[i] = 0.0;
|
||||
}
|
||||
}
|
||||
@@ -301,5 +305,9 @@ std::pair <std::shared_ptr<NeuralNetwork::Neuron>, std::vector<float>> CascadeCo
|
||||
while(iterations++ < _maxCandidateIterations && iterationsWithoutIprovement < _maxCandidateIterationsWithoutChange);
|
||||
std::cout << "iter: " << iterations << ", correlation: " << bestCorrelation << ", " << lastCorrelation << "\n";
|
||||
|
||||
for(auto&a: bestCorrelations) {
|
||||
a*=-1.0;
|
||||
}
|
||||
|
||||
return {bestCandidate, bestCorrelations};
|
||||
}
|
||||
Reference in New Issue
Block a user