Код на С
#include <stdio.h>
#include "floatfann.h"
int main()
{
fann_type *calc_out;
fann_type input[2];
struct fann *ann = fann_create_from_file("xor_float.net");
input[0] = -1;
input[1] = 1;
calc_out = fann_run(ann, input);
printf("xor test (%f,%f) -> %f\n", input[0], input[1], calc_out[0]);
input[0] = 1;
input[1] = -1;
calc_out = fann_run(ann, input);
printf("xor test (%f,%f) -> %f\n", input[0], input[1], calc_out[0]);
input[0] = -1;
input[1] = -1;
calc_out = fann_run(ann, input);
printf("xor test (%f,%f) -> %f\n", input[0], input[1], calc_out[0]);
input[0] = 1;
input[1] = 1;
calc_out = fann_run(ann, input);
printf("xor test (%f,%f) -> %f\n", input[0], input[1], calc_out[0]);
fann_destroy(ann);
return 0;
}
xor test (-1.000000,1.000000) -> 0.999761
xor test (1.000000,-1.000000) -> 0.999784
xor test (-1.000000,-1.000000) -> -0.999978
xor test (1.000000,1.000000) -> -0.999823
from pyfann import fann
ann = fann.create_from_file('xor_float.net')
print '%f' % ann.run((-1,1))[0]
print '%f' % ann.run((1,-1))[0]
print '%f' % ann.run((-1,-1))[0]
print '%f' % ann.run((1,1))[0]
8783949685095173301117427223208394752.000000
0.000000
0.000000
8784890281840542647333337776986783744.000000