I’ve been experimenting with the FANN library, which seems to be a great library for neural network, and I’m having some issue on how to use it.
So what I’m trying to do here is training a neural network, for the sake of messing with the library, giving it an input and expecting an output.
FANN::neural_net nn;
const float desired_error = 0.00001;
const unsigned int max_epochs = 500000;
const unsigned int epochs_between_reports = 1000;
const unsigned int layers_count = 3;
const unsigned int layers[layers_count] = {7, 5, 1};
nn.create_standard_array(layers_count, layers);
nn.train_on_file(TRAINING_DATA, max_epochs, epochs_between_reports, desired_error);
Here are the first lines of my training data file (TRAINING_DATA) :
16969 7 1
0.0812069 0.0812069 0.381578 0.0812069 5.8931e-05 0.0843302 0.606695
1
0.429961 0.0509753 0.381578 0.0266957 0.000117862 0.00707172 0.0221581
1
0.0983558 0.486888 0.381578 0.000117862 0.0266957 0.00701279 0.0539808
1
0.0983558 0.486888 0.598562 0.0161471 0.0161471 0.000471448 0.00135541
1
The complete dataset can be found here
Using a sample data from the training data file, I should get the output matching it, right? However, if I do the following, I get 0 as output…
fann_type i[7], *o;
i[0] = 0.429961; i[1] = 0.0509753; i[2] = 0.381578; i[3] = 0.0266957; i[4] = 0.000117862; i[5] = 0.00707172; i[6] = 0.0221581;
o = nn.run(i);
std::cout << "output (run) is " << o[0] << std::endl;
Can someone actually explain me what is going on here?
I use the 2.2.0 version of fann.
Thank you
Edit : It seems that the 2.1.0 beta version give the expected results, but not the 2.2.0 version.
Edit 2 : It was actually a bug in the version I was using.
I tried to reproduce your error but I could not. Here is my program:
This is the output:
Maybe you could provide your full training set?