Missing Indexes
This commit is contained in:
parent
c6e96d71a8
commit
1b0156a8ea
16
Genetic.cpp
16
Genetic.cpp
|
@ -688,14 +688,14 @@ double RandomDouble(int min, int max)
|
||||||
void SetInput(double, int);
|
void SetInput(double, int);
|
||||||
void NextGeneration();
|
void NextGeneration();
|
||||||
void WriteBestToFile();
|
void WriteBestToFile();
|
||||||
void UpdateScores();
|
void UpdateScores(int);
|
||||||
void ResetScores();
|
void ResetScores();
|
||||||
bool CreateNetworks(int, int);
|
bool CreateNetworks(int, int);
|
||||||
bool ConnectNetworks();
|
bool ConnectNetworks();
|
||||||
bool SetInputNeurons(int);
|
bool SetInputNeurons(int);
|
||||||
bool SetHiddenNeurons(int, int);
|
bool SetHiddenNeurons(int, int);
|
||||||
bool SetOutputNeurons(int);
|
bool SetOutputNeurons(int);
|
||||||
double GetBestPrediction(int);
|
double GetPredictionOfBestNetwork(int);
|
||||||
double GetError(int);
|
double GetError(int);
|
||||||
int GetStep();
|
int GetStep();
|
||||||
};
|
};
|
||||||
|
@ -770,13 +770,13 @@ double RandomDouble(int min, int max)
|
||||||
std::cout << "Target -> " << target << "\tBest -> " << networks -> GetPrediction(index) << "\n";
|
std::cout << "Target -> " << target << "\tBest -> " << networks -> GetPrediction(index) << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
void Generation::UpdateScores()
|
void Generation::UpdateScores(int index = 0)
|
||||||
{
|
{
|
||||||
double scoreToAdd;
|
double scoreToAdd;
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < size; i++)
|
for (i = 0; i < size; i++)
|
||||||
{
|
{
|
||||||
scoreToAdd = (networks + i) -> GetError(0, target);
|
scoreToAdd = (networks + i) -> GetError(index, target);
|
||||||
(networks + i) -> SetScore((networks + i) -> GetScore() + scoreToAdd);
|
(networks + i) -> SetScore((networks + i) -> GetScore() + scoreToAdd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -788,7 +788,7 @@ double RandomDouble(int min, int max)
|
||||||
(networks + i) -> SetScore(0.0);
|
(networks + i) -> SetScore(0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
double Generation::GetBestPrediction(int index = 0)
|
double Generation::GetPredictionOfBestNetwork(int index = 0)
|
||||||
{
|
{
|
||||||
return networks -> GetPrediction(index);
|
return networks -> GetPrediction(index);
|
||||||
}
|
}
|
||||||
|
@ -990,7 +990,7 @@ int main()
|
||||||
generation.NextGeneration();
|
generation.NextGeneration();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::cout << "Best Score -> " << generation.GetBestPrediction() << "\n";
|
std::cout << "Best Score -> " << generation.GetPredictionOfBestNetwork() << "\n";
|
||||||
std::cout << "Train is Over!\n";
|
std::cout << "Train is Over!\n";
|
||||||
// break; To test it after the train is done
|
// break; To test it after the train is done
|
||||||
case -1:
|
case -1:
|
||||||
|
@ -1002,8 +1002,8 @@ int main()
|
||||||
generation.SetTarget(testInputs[inputCounter][4]);
|
generation.SetTarget(testInputs[inputCounter][4]);
|
||||||
|
|
||||||
generation.Fire();
|
generation.Fire();
|
||||||
currentError = testInputs[inputCounter][4] - generation.GetBestPrediction() < 0 ? generation.GetBestPrediction() - testInputs[inputCounter][4] : testInputs[inputCounter][4] - generation.GetBestPrediction();
|
currentError = testInputs[inputCounter][4] - generation.GetPredictionOfBestNetwork() < 0 ? generation.GetPredictionOfBestNetwork() - testInputs[inputCounter][4] : testInputs[inputCounter][4] - generation.GetPredictionOfBestNetwork();
|
||||||
fprintf(outputFile, "%lf,%lf,%lf\n", testInputs[inputCounter][4], generation.GetBestPrediction(), currentError);
|
fprintf(outputFile, "%lf,%lf,%lf\n", testInputs[inputCounter][4], generation.GetPredictionOfBestNetwork(), currentError);
|
||||||
}
|
}
|
||||||
fclose(outputFile);
|
fclose(outputFile);
|
||||||
std::cout << "Test is Over!\n";
|
std::cout << "Test is Over!\n";
|
||||||
|
|
Loading…
Reference in New Issue