简体   繁体   English

FANN神经网络-恒定结果

[英]FANN Neural Network - constant result

I'm using the FANN Library with the given code. 我正在使用带有给定代码的FANN库。

#include <stdio.h>
#include "doublefann.h"
int main()
{
    const NUM_ITERATIONS = 10000;
    struct fann *ann;
    int topology[] = { 1, 4, 1 };
    fann_type d1[1] = { 0.5 };
    fann_type d2[1] = { 0.0 };
    fann_type *pres;
    int i;

    /* Create network */
    ann = fann_create_standard_array(3, topology);

    /* 
     * Train network 
     * input: 0.0 => output: 0.5
     * input: 0.5 => output: 0.0
     */
    i = NUM_ITERATIONS;
    while (--i)
    {
        fann_train(ann, d1, d2);
        fann_train(ann, d2, d1);
    }

    /* Should return 0.5 */
    pres = fann_run(ann, d2);
    printf("%f\n", pres[0]);

    /* Should return 0.0 */
    pres = fann_run(ann, d1);
    printf("%f\n", pres[0]);

    /* Destroy network */
    fann_destroy(ann);

    return 0;
}

I expected the result of the first run to be 0.5, since according to the training the output value to an input value of 0.0 shall be 0.5. 我期望第一次运行的结果为0.5,因为根据训练,输入值为0.0的输出值为0.5。 Accordingly I expected the output of the second run to be 0.0. 因此,我期望第二次运行的输出为0.0。

But the result is constant 0.0 for every of these two runs. 但是对于这两个运行中的每一个,结果都是常数0.0。

What am I missing here? 我在这里想念什么?

从此站点 :尝试用doublefann.h替换fann.h

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM