Reputation: 21
I was trying this code but i get error, I can't solve this problem!
anybody have idea?
#include<iostream>
using namespace std;
#include <cv.h>
#include <highgui.h>
#include <fann.h>
#include <fann_cpp.h>
#include <floatfann.h>
int main()
{
const float connection_rate = 1;
const float learning_rate = 0.7;
const unsigned int num_layers = 3;
const unsigned int num_input = 2;
const unsigned int num_neurons_hidden = 4;
const unsigned int num_output = 1;
const float desired_error = 0.0001;
const unsigned int max_epochs = 500000;
const unsigned int epochs_between_reports = 1000;
FANN::neural_net ann;
ann.create_standard(num_layers,num_input, num_neurons_hidden, num_output,connection_rate,learning_rate);
ann.train_on_file("C:\\xor.data", max_epochs,epochs_between_reports, desired_error);
ann.save("C:\\xor_float.net");
ann.destroy();
return 0;
}
xor.data:
4 2 1
0 0
0
0 1
1
1 0
1
1 1
0
The error was: FANN Error 1: Unable to open configuration file "C:\xor.data" for reading.
Thanks.
Upvotes: 0
Views: 1272
Reputation: 99094
Maha, you have a main
routine here with half a dozen custom headers (which we can't see) and two calls involving the filename (which we can't see). If the answer isn't obvious, e.g. the file doesn't exist, then simplify.
I'll bet four of those five headers are unnecessary; remove them. Open up the train_on_file_
method and eviscerate it, remove everything but the lines that open the file and read a value or two. Do this piecemeal, testing for the error at every step. Either
Upvotes: 1
Reputation: 15566
This probably means that you need to have a file named xor.data in your C drive and that file will contain the configuration information.
Upvotes: 0