0

I am using the FANN Library to build neural networks to proceed a regression problem. The thing is, once the networks has been trained on the relevant training set (which seems to work quite well), every single test output the exact same output. In other words, given any state of my 16 predictive variables, my predicted output, according the the ANN, is the same.

My guess would be that the network is correctly computing the first line of the calculation, then always outputs this result on other calculations, no matter what I feed it (as it seems to do very well on the first training example, giving an accurate prediction).

For instance, my first training example variables are:

1 1 13.5 13.5 13.5 14.5 14.4 14.3 14.3 14.2 14.5 13 11.7 12.2 12.2 11.3 

My target output is 14.5, and on each test, the network outputs something between 14.69 and 14.7 (due to small calculation times and as I am only playing with the package, I train it each time I run the code). So, this output seems completely legitimate with that set of data.

The thing is, when I try to run it on several other inputs, I always get that same 14.69/14.7 (identical output on even the smallest digit).

Since the network seems to be correctly processing the training example, learning the relationship and calculatting correctly on ONE new test example, I tend to believe that all the training part is correct. Since there is no reason the network would always output the same value, my guess is that my way of testing it is not correct.

My question is: what is the exact syntax to test a FANN neural network on a new dataset? and, how do I print/save the corresponding outputs?

Here is the current state of my code:

fann_type *calc_out;
fann_type input[16];

for (int i = 0; i < 20; i++)
{
    if (!rowHasNA(timeSerie, i))
    {
        cout << "Input : ";
        for (int j = 1; j < 17; j++)
        {
            input[j - 1] = timeSerie(i, j);
            cout << input[j - 1] << " ";
        }
        cout << endl;
        calc_out = fann_run(ann, input);
        cout << "Input " << i << " gives : " << calc_out[0] << endl;
    }
}

Where:

  • rowHasNA is a custom function I used to determine whether my example has at least one NA
  • ann is a fann* which has already been trained
  • timeSerie is a matrix<double> where each line is a test example

I am still a bit confused on how the FANN package works, since I have found no really clear documentation on how to train networks and test them. I struggle to understand how the fann_type works.

Thank you in advance.

4

1 回答 1

1

敬启者。

上面写的代码是正确的:在网络经过适当训练的情况下,它设法为不同的输入输出不同的值。

主要问题是训练网络。因为它给了我一个正确的答案(14.7,非常接近预期的 14.5),所以我认为它已经过适当的训练。实际上,它不是,而是给出了与训练目标相对应的“最佳平均值”。由于我的训练集几乎没有差异,无论输入什么输入,总是输出相同的值,给出了一个不错的 MSE(虽然,比我在 R 和 Octave 中的差得多,但因为我从未使用过 FANN,所以我做了不知道会发生什么)。

解决方案很简单,我早该想到的:特征缩放。

考虑到我在 Internet 上看到的一些文献,我假设该软件包正在自行扩展功能。使用最基本的代码来训练网络,特征缩放不适用于训练集。

我建议在 0 和 1 (x - min / max - min) 之间缩放特征。

于 2015-05-29T02:06:53.083 回答