Andrew Shacklock
2012-09-03 21:34:30 UTC
Using the XOR training sample template I have created the below function,
which is having problems with fann_save: sometimes it doesn't seem to save
the "ann_.net" file and I have to run the function as many as 5 times
before a file is saved/written to the current directory.
#include "fann.h"
int main()
{
const unsigned int num_input = 102;
const unsigned int num_output = 5;
const unsigned int num_layers = 3;
const unsigned int num_neurons_hidden = 102;
const float desired_error = (const float) 0.001;
const unsigned int max_epochs = 200;
const unsigned int epochs_between_reports = 10;
struct fann *ann = fann_create_standard(num_layers, num_input,
num_neurons_hidden, num_output);
fann_set_activation_function_hidden(ann, FANN_SIGMOID);
fann_set_activation_function_output(ann, FANN_SIGMOID);
fann_train_on_file(ann, "data_for_training_out-train.dat", max_epochs,
epochs_between_reports, desired_error);
fann_save(ann, "ann_.net");
fann_destroy(ann);
return 0;
}
Is there a problem with my coding? If not, may be the problem is how I
compiled it. gcc net_train.c -o net_train -lfann -lm didn't work so I
copied the makefile file from the samples directory and changed the TARGETS
line to: TARGETS = net_train and then compiled by issuing "make" in the
terminal. No other changes were made to the makefile.
which is having problems with fann_save: sometimes it doesn't seem to save
the "ann_.net" file and I have to run the function as many as 5 times
before a file is saved/written to the current directory.
#include "fann.h"
int main()
{
const unsigned int num_input = 102;
const unsigned int num_output = 5;
const unsigned int num_layers = 3;
const unsigned int num_neurons_hidden = 102;
const float desired_error = (const float) 0.001;
const unsigned int max_epochs = 200;
const unsigned int epochs_between_reports = 10;
struct fann *ann = fann_create_standard(num_layers, num_input,
num_neurons_hidden, num_output);
fann_set_activation_function_hidden(ann, FANN_SIGMOID);
fann_set_activation_function_output(ann, FANN_SIGMOID);
fann_train_on_file(ann, "data_for_training_out-train.dat", max_epochs,
epochs_between_reports, desired_error);
fann_save(ann, "ann_.net");
fann_destroy(ann);
return 0;
}
Is there a problem with my coding? If not, may be the problem is how I
compiled it. gcc net_train.c -o net_train -lfann -lm didn't work so I
copied the makefile file from the samples directory and changed the TARGETS
line to: TARGETS = net_train and then compiled by issuing "make" in the
terminal. No other changes were made to the makefile.