Search code examples
c++fann

ANN training progress resets every new training session using FANN


I have a standard neural network which I have trained for some time, but not until perfection. After the training session is complete, I save the network on disk.

After some time I want to resume training the network from where it left. The problem is, it seems that every time I start a new training session, the weights and biases seem to be totally reset, which means I'm training the network from scratch all over again:

Previous session:

enter image description here

New session:

enter image description here

Here is the excerpt from my training function:

void trainNet(fann *net) {
    const unsigned int
        max_epochs = 1000,
        epochs_between_reports = 10;
    const float desired_error = 0.01f;
    net -> learning_momentum = 0.1f;
    fann_train_on_file(net, "sessions.data", max_epochs, epochs_between_reports, desired_error);
    fann_save(net, "network.net");
    fann_destroy(net);
}

What am I missing? It seems so intuitive to me that you could train a network over a span of multiple sessions. Am I wrong? Is it a limitation of the library?

The training data has remained constant between sessions. This isn't limited to this specific network, either -- networks of any format seem to invoke the same issue.


Solution

  • What am I missing?

    As per Documentation - FANN Training > Training Data Manipulation > fann_set_training_algorithm :

    Set the training algorithm.

    Example :

    fann_set_training_algorithm(net, FANN_TRAIN_INCREMENTAL)