Skip to content

3.5. Prediction

useAIble edited this page May 10, 2017 · 1 revision

After processing the data, we will now check if our engine has learned from the training session. Note that the only difference with Predict from training is that we put ‘false’ to the learn argument on the Cycle.RunCycle() method and of course, the inputs which we used our xor table to check if the RLM has learned as expected. This should be outside the training sessions loop.

long SessionID = rlmNet.SessionStart();
sumOfCycleScores = 0;

foreach (var xor in xorTable)
{
	var invs = new List<RlmIOWithValue>();
 	invs.Add(new RlmIOWithValue(rlmNet.Inputs.First(a => a.Name == "XORInput1"), xor.Input1));
 	invs.Add(new RlmIOWithValue(rlmNet.Inputs.First(a => a.Name == "XORInput2"), xor.Input2));

 	RlmCycle Cycle = new RlmCycle();
 	RlmCyclecompleteArgs result = Cycle.RunCycle(rlmNet, SessionID, invs, false);

 	double score = ScoreCycle(result, xor, true);

     sumOfCycleScores += score;

 // sets the score
 rlmNet.ScoreCycle(result.CycleOutput.CycleID, score);

}
rlmNet.SessionEnd(sumOfCycleScores);

Then we will need to call the TrainingDone() method to notify all events that we are done, and the Data Persistence is notified

rlmNet.TrainingDone();
Console.ReadLine();

And finally, we have the output: