|
From: Herton R. K. <he...@us...> - 2005-07-08 23:38:49
|
Update of /cvsroot/kimageprocess/kimageprocess/testclass In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10598 Modified Files: testclass.c Log Message: - Duh: I forgot that activation functions can be modified also in run process, so fixing this now. Index: testclass.c =================================================================== RCS file: /cvsroot/kimageprocess/kimageprocess/testclass/testclass.c,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- testclass.c 8 Jul 2005 22:57:36 -0000 1.19 +++ testclass.c 8 Jul 2005 23:38:36 -0000 1.20 @@ -27,16 +27,16 @@ fprintf(stderr, " Gustavo Pichorim Boiko <gus...@kd...>\n"); fprintf(stderr, " Herton Ronaldo Krzesinski <he...@my...>\n\n"); fprintf(stderr, "Usage: %s [options]\n", progname); - fprintf(stderr, "Options: -t,--train-pattern trainpatternfile\n"); - fprintf(stderr, " -c,--classify-pattern classifypatternfile\n"); - fprintf(stderr, " -r,--res-file resfile\n"); - fprintf(stderr, " -h,--activation-function-hidden, FANN_THRESHOLD\n"); - fprintf(stderr, " -o,--activation-function-output FANN_THRESHOLD_SYMMETRIC\n"); - fprintf(stderr, " FANN_LINEAR\n"); - fprintf(stderr, " FANN_SIGMOID\n"); - fprintf(stderr, " FANN_SIGMOID_STEPWISE\n"); - fprintf(stderr, " FANN_SIGMOID_SYMMETRIC\n"); - fprintf(stderr, " FANN_SIGMOID_SYMMETRIC_STEPWISE\n"); + fprintf(stderr, "Options: -t,--train-pattern trainpatternfile\n"); + fprintf(stderr, " -c,--classify-pattern classifypatternfile\n"); + fprintf(stderr, " -r,--res-file resfile\n"); + fprintf(stderr, " -h,--activation-function-hidden-t, FANN_THRESHOLD\n"); + fprintf(stderr, " -o,--activation-function-output-t, FANN_THRESHOLD_SYMMETRIC\n"); + fprintf(stderr, " -s,--activation-function-hidden-c, FANN_LINEAR\n"); + fprintf(stderr, " -p,--activation-function-output-c FANN_SIGMOID\n"); + fprintf(stderr, " FANN_SIGMOID_STEPWISE\n"); + fprintf(stderr, " FANN_SIGMOID_SYMMETRIC\n"); + fprintf(stderr, " FANN_SIGMOID_SYMMETRIC_STEPWISE\n"); exit(1); } @@ -174,8 +174,10 @@ {"train-pattern", 1, NULL, 't'}, {"classify-pattern", 1, NULL, 'c'}, {"res-file", 1, NULL, 'r'}, - {"activation-function-hidden", 1, NULL, 'h'}, - {"activation-function-output", 1, NULL, 'o'}, + {"activation-function-hidden-t", 1, NULL, 'h'}, + {"activation-function-output-t", 1, NULL, 'o'}, + {"activation-function-hidden-c", 1, NULL, 's'}, + {"activation-function-output-c", 1, NULL, 'p'}, {0, 0, 0, 0} }; opterr = 0; @@ -188,7 +190,7 @@ float connection_rate = 1; float learning_rate = 0.7; float *result; - int npat, _func, h_func, o_func; + int npat, _func, h_func, o_func, s_func, p_func; time_t tempTime; if (argc == 1) @@ -199,6 +201,8 @@ r_file = NULL; h_func = FANN_SIGMOID_SYMMETRIC_STEPWISE; o_func = FANN_SIGMOID_SYMMETRIC_STEPWISE; + s_func = FANN_SIGMOID_SYMMETRIC_STEPWISE; + p_func = FANN_SIGMOID_SYMMETRIC_STEPWISE; while (1) { c = getopt_long (argc, argv, "+t:c:r:a:", long_options, &option_index); @@ -219,6 +223,8 @@ break; case 'h': case 'o': + case 's': + case 'p': if (!strncmp(optarg, "FANN_THRESHOLD_SYMMETRIC", strlen("FANN_THRESHOLD_SYMMETRIC"))) { _func = FANN_THRESHOLD_SYMMETRIC; goto assign_function; @@ -251,11 +257,18 @@ usage(argv[0]); break; assign_function: - if (c == 'h' && _func != FANN_THRESHOLD_SYMMETRIC - && _func != FANN_THRESHOLD) - h_func = _func; - else if (c == 'o') - o_func = _func; + /* training activation functions cannot be of THRESHOLD type */ + if (c == 'h' || c == 'o' && _func != FANN_THRESHOLD_SYMMETRIC + && _func != FANN_THRESHOLD) { + if (c == 'h') + h_func = _func; + else + o_func = _func; + } + else if (c == 's') + s_func = _func; + else if (c == 'p') + p_func = _func; break; case ':': case '?': @@ -293,7 +306,9 @@ tfanndata.input = t_patData.inputValues; tfanndata.output = t_patData.outputValues; fann_init_weights(tfann, &tfanndata); - fann_train_on_data(tfann, &tfanndata, 300000, 1000, 0.001); + fann_train_on_data(tfann, &tfanndata, 46000, 460, 0.001); + fann_set_activation_function_hidden(tfann, s_func); + fann_set_activation_function_output(tfann, p_func); if (fprintf(pr_file, "SNNS result file V1.4-3D\n") < 0) fatal(errno); tempTime = time(NULL); |