Commit 43109655 authored by Vivien Kraus's avatar Vivien Kraus
Browse files

Print the models rarely

parent e5849ef7
...@@ -456,44 +456,41 @@ self_learn (TarotPerceptron * perceptron) ...@@ -456,44 +456,41 @@ self_learn (TarotPerceptron * perceptron)
} }
} }
metric = tarot_perceptron_validate (perceptron, game); metric = tarot_perceptron_validate (perceptron, game);
if (!is_empty_game (game))
{
double *data = NULL, max_weight = 0;
size_t n = 0, w;
double update = tarot_perceptron_learn_game (perceptron, game);
tarot_perceptron_save_alloc (perceptron, &n, &data);
for (w = 0; w < n; w++)
{
if (w != 0)
{
printf ("\t");
}
printf ("%f", data[w]);
if (data[w] > max_weight || -data[w] > max_weight)
{
if (data[w] > max_weight)
{
max_weight = data[w];
}
else
{
max_weight = -data[w];
}
}
}
printf ("\n");
fprintf (stderr, "%g\t%g\t%g\t%g\n", current_exploration, update,
metric, max_weight);
free (data);
}
if (--until_print_game == 0) if (--until_print_game == 0)
{ {
if (!is_empty_game (game)) if (!is_empty_game (game))
{ {
char *data = tarot_game_save_to_xml_alloc (game); double *weights = NULL, max_weight = 0;
fprintf (stderr, "%s\n", data); size_t n = 0, w;
free (data); double update = tarot_perceptron_learn_game (perceptron, game);
} char *xml = tarot_game_save_to_xml_alloc (game);
tarot_perceptron_save_alloc (perceptron, &n, &weights);
for (w = 0; w < n; w++)
{
if (w != 0)
{
printf ("\t");
}
printf ("%f", weights[w]);
if (weights[w] > max_weight || -weights[w] > max_weight)
{
if (weights[w] > max_weight)
{
max_weight = weights[w];
}
else
{
max_weight = -weights[w];
}
}
}
printf ("\n");
fprintf (stderr, "%g\t%g\t%g\t%g\n", current_exploration, update,
metric, max_weight);
free (weights);
fprintf (stderr, "%s\n", xml);
free (xml);
}
until_print_game = 100; until_print_game = 100;
} }
tarot_game_free (game); tarot_game_free (game);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment