Skip to content
Snippets Groups Projects
Commit 9e8e91be authored by Franck Dary's avatar Franck Dary
Browse files

Probably fixed error prediction

parent 52c6bdfd
Branches
No related tags found
No related merge requests found
......@@ -347,6 +347,8 @@ void Trainer::doStepTrain()
}
actionName = pAction;
if (choiceWithProbability(0.5))
actionName = oAction;
char buffer[1024];
if (sscanf(tm.getCurrentClassifier()->name.c_str(), "Error_%s", buffer) != 1)
......@@ -361,7 +363,7 @@ void Trainer::doStepTrain()
auto & normalHistory = trainConfig.getActionsHistory(normalClassifierName);
// If a BACK just happened
if (normalHistory.size() > 1 && errorHistory.size() > 0 && TI.getEpoch() >= ProgramParameters::dynamicEpoch)
if (normalHistory.size() > 1 && trainConfig.getCurrentStateHistory().size() > 0 && trainConfig.getCurrentStateHistory().top() != "EPSILON" && TI.getEpoch() >= ProgramParameters::dynamicEpoch)
{
auto & lastAction = normalHistory[normalHistory.size()-2];
auto & newAction = normalHistory[normalHistory.size()-1];
......
......@@ -29,7 +29,8 @@ class Action
{
Push,
Pop,
Write
Write,
Back
};
/// @brief The type of this BasicAction.
......
......@@ -134,7 +134,7 @@ class Config
private :
const unsigned int HISTORY_SIZE = 1000;
const unsigned int HISTORY_SIZE = 100000;
/// @brief The name of the current state of the TransitionMachine.
std::string currentStateName;
/// @brief For each state of the TransitionMachine, an history of the Action that have been applied to this Config.
......
......@@ -10,7 +10,7 @@ void Action::apply(Config & config)
for(auto & basicAction : sequence)
basicAction.apply(config, basicAction);
config.getCurrentStateHistory().push(namePrefix);
config.getCurrentStateHistory().push(name);
config.pastActions.push(std::pair<std::string, Action>(config.getCurrentStateName(), *this));
config.moveHead(headMovement);
......@@ -48,7 +48,7 @@ void Action::undoOnlyStack(Config & config)
for(int i = sequence.size()-1; i >= 0; i--)
{
auto type = sequence[i].type;
if(type == BasicAction::Type::Write)
if(type == BasicAction::Type::Write || type == BasicAction::Type::Back)
continue;
sequence[i].undo(config, sequence[i]);
......@@ -57,6 +57,8 @@ void Action::undoOnlyStack(Config & config)
if (ProgramParameters::debug)
fprintf(stderr, "Undoing only stack action <%s><%s>, state history size = %d past actions size = %d...", stateName.c_str(), name.c_str(), config.getStateHistory(stateName).size(), config.pastActions.size());
char buffer[1024];
if (sscanf(stateName.c_str(), "error_%s", buffer) != 1)
config.getStateHistory(stateName).pop();
if (ProgramParameters::debug)
......
......@@ -578,7 +578,7 @@ std::vector<Action::BasicAction> ActionBank::str2sequence(const std::string & na
return true;
};
Action::BasicAction basicAction =
{Action::BasicAction::Type::Write, "", apply, undo, appliable};
{Action::BasicAction::Type::Back, name, apply, undo, appliable};
sequence.emplace_back(basicAction);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment