I'm using the FANN Library with the given code.
#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. Accordingly I expected the output of the second run to be 0.0.
But the result is constant 0.0 for every of these two runs.
What am I missing here?
From this site: Try to replace doublefann.h
by fann.h
.