|
From: Herton R. K. <he...@us...> - 2005-04-06 04:32:20
|
Update of /cvsroot/kimageprocess/kimageprocess/testclass In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30359/testclass Modified Files: Makefile.am testclass.c Log Message: - Added training code for tests. Index: Makefile.am =================================================================== RCS file: /cvsroot/kimageprocess/kimageprocess/testclass/Makefile.am,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- Makefile.am 5 Apr 2005 06:54:55 -0000 1.4 +++ Makefile.am 6 Apr 2005 04:32:11 -0000 1.5 @@ -5,7 +5,9 @@ noinst_PROGRAMS = testclass # set the include path for X, qt and KDE -INCLUDES = $(all_includes) -I$(srcdir)/../testclass +INCLUDES = $(all_includes) \ + -I$(srcdir)/../testclass \ + -I$(srcdir)/../testclass/libfann/include # the library search path. testclass_LDFLAGS = $(all_libraries) @@ -13,7 +15,7 @@ # the libraries to link against. testclass_LDADD = $(top_builddir)/testclass/libfann/libfann.a \ $(top_builddir)/testclass/libfann/libfloatfann.a \ - -lfl + -lfl -lm # which sources should be compiled for testclass testclass_SOURCES = testclass.c Index: testclass.c =================================================================== RCS file: /cvsroot/kimageprocess/kimageprocess/testclass/testclass.c,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- testclass.c 6 Apr 2005 03:00:14 -0000 1.13 +++ testclass.c 6 Apr 2005 04:32:11 -0000 1.14 @@ -5,6 +5,7 @@ #include <string.h> #include <unistd.h> #include <lex.yy.c> +#include <fann.h> #define TESTCLASS_VERSION "0.1" #define PARSER_ERROR 1 @@ -176,12 +177,12 @@ opterr = 0; char *t_file, *c_file, *r_file; FILE *pt_file, *pc_file, *pr_file; - int in_tnum, out_tnum, pat_tnum; - float **in_tvalues, **out_tvalues; - int in_cnum, out_cnum, pat_cnum; - float **in_cvalues, **out_cvalues; pat t_patData; pat c_patData; + struct fann *tfann; + struct fann_train_data tfanndata; + float connection_rate = 1; + float learning_rate = 0.7; if (argc == 1) usage(argv[0]); @@ -226,6 +227,24 @@ if (pc_file == NULL) fatal(errno); loadNetwork(&c_patData, pc_file, c_file); + tfann = fann_create(connection_rate, learning_rate, 3, + t_patData.numInputUnits, + t_patData.numInputUnits, + t_patData.numOutputUnits); + fann_set_activation_steepness_hidden(tfann, 1.0); + fann_set_activation_steepness_output(tfann, 1.0); + fann_set_activation_function_hidden(tfann, FANN_SIGMOID_SYMMETRIC_STEPWISE); + fann_set_activation_function_output(tfann, FANN_SIGMOID_SYMMETRIC_STEPWISE); + tfanndata.num_data = t_patData.numPatterns; + tfanndata.num_input = t_patData.numInputUnits; + tfanndata.num_output = t_patData.numOutputUnits; + tfanndata.input = t_patData.inputValues; + tfanndata.output = t_patData.outputValues; + fann_init_weights(tfann, &tfanndata); + /*fann_set_training_algorithm(ann, FANN_TRAIN_QUICKPROP);*/ + fann_train_on_data(tfann, &tfanndata, 300000, 1000, 0.001); + /*fann_train_on_data_callback(ann, data, max_iterations, iterations_between_reports, desired_error, print_callback);*/ + fann_destroy(tfann); if (t_patData.inputValues != NULL) { /* free only first element because is a contiguous allocated memory |