开发者

FANN Error 1: unable to open file

开发者 https://www.devze.com 2023-02-19 12:39 出处:网络
I was trying this code but i get error, I can\'t solve this problem! anybody have idea? #include<iostream>

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开发者_如何学Go = 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.


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

  1. the error will disappear (the part you just removed was causing the problem),
  2. the bug will become obvious, or
  3. you'll get down to something small which should work but doesn't, which you can then post in its entirety.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号