0

I would like to make a neural network model to perform a regression task on some data using the dlib(dlib-19.1) library in c++(in visual studio(VS) 2013). Here is a link on how to set dlib with VS 2013. The code I have tried for this task is listed bellow, however I do not get correct results... I have searched the internet for a solution and I did not find anything helpful...

typedef matrix<double, 7, 1> sample_type;
typedef matrix<double, 2, 1> truth;

sample_type sample[10000];
truth gt[10000];

//// Create a multi-layer perceptron network.    
mlp::kernel_1a_c net(7, 6,0,2);

ifstream fin("E:\\dataNN.txt");
int index = 0;
while (!fin.eof())
{
    fin >> sample[index](0) >> sample[index](1) >> sample[index](2) >> sample[index](3) >> sample[index](4) >> sample[index](5) >> sample[index](6) >> gt[index](0) >> gt[index](1);
    index++;
}
fin.close();
for (int i = 0; i < 1000; ++i)
{
    for (int j = 0; j < 90; j++)
    {
        net.train(sample[j], gt[j]);
    }
    cout << "Epoch " << i << "\n";
}

for (int j = 91; j < 106; j++)
    cout << "This sample should be close to " << gt[j](0) << " " << gt[j](1) << " net result " << net(sample[j])(0) << " " << net(sample[j])(1) << "\n";

Can anyone give me a hint on how can I solve this issue?

  • 2
    `while (!fin.eof())` -- [Please read this about eof()](https://stackoverflow.com/questions/5605125/why-is-iostreameof-inside-a-loop-condition-considered-wrong) – PaulMcKenzie Feb 13 '18 at 16:36
  • *however I do not get correct results.* -- What are the "correct results" and what results are you getting now? – PaulMcKenzie Feb 13 '18 at 16:39
  • When I say correct results I refer to the similarity with the ground truth. For example :This sample should be close to 26.5779 -2.2356 net result 1 1.42806e-006 This sample should be close to 25.7946 -2.25045 net result 1 1.42806e-006 – Mircea Paul Muresan Feb 14 '18 at 08:48

0 Answers0