|
From: Herton R. K. <he...@us...> - 2005-07-08 22:57:46
|
Update of /cvsroot/kimageprocess/kimageprocess/testclass In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21167 Modified Files: testclass.c Log Message: - Added options to select different activation functions for hidden and output layers. Index: testclass.c =================================================================== RCS file: /cvsroot/kimageprocess/kimageprocess/testclass/testclass.c,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- testclass.c 23 Jun 2005 22:38:08 -0000 1.18 +++ testclass.c 8 Jul 2005 22:57:36 -0000 1.19 @@ -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, " -a,--activation-function FANN_THRESHOLD\n"); - fprintf(stderr, " 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, 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"); exit(1); } @@ -174,7 +174,8 @@ {"train-pattern", 1, NULL, 't'}, {"classify-pattern", 1, NULL, 'c'}, {"res-file", 1, NULL, 'r'}, - {"activation-function", 1, NULL, 'a'}, + {"activation-function-hidden", 1, NULL, 'h'}, + {"activation-function-output", 1, NULL, 'o'}, {0, 0, 0, 0} }; opterr = 0; @@ -187,7 +188,7 @@ float connection_rate = 1; float learning_rate = 0.7; float *result; - int npat, a_func; + int npat, _func, h_func, o_func; time_t tempTime; if (argc == 1) @@ -196,7 +197,8 @@ t_file = NULL; c_file = NULL; r_file = NULL; - a_func = FANN_SIGMOID_SYMMETRIC_STEPWISE; + h_func = FANN_SIGMOID_SYMMETRIC_STEPWISE; + o_func = FANN_SIGMOID_SYMMETRIC_STEPWISE; while (1) { c = getopt_long (argc, argv, "+t:c:r:a:", long_options, &option_index); @@ -215,38 +217,46 @@ case 'r': r_file = optarg; break; - case 'a': + case 'h': + case 'o': if (!strncmp(optarg, "FANN_THRESHOLD_SYMMETRIC", strlen("FANN_THRESHOLD_SYMMETRIC"))) { - a_func = FANN_THRESHOLD_SYMMETRIC; - break; + _func = FANN_THRESHOLD_SYMMETRIC; + goto assign_function; } if (!strncmp(optarg, "FANN_THRESHOLD", strlen("FANN_THRESHOLD"))) { - a_func = FANN_THRESHOLD; - break; + _func = FANN_THRESHOLD; + goto assign_function; } if (!strncmp(optarg, "FANN_LINEAR", strlen("FANN_LINEAR"))) { - a_func = FANN_LINEAR; - break; + _func = FANN_LINEAR; + goto assign_function; } if (!strncmp(optarg, "FANN_SIGMOID_SYMMETRIC_STEPWISE", strlen("FANN_SIGMOID_SYMMETRIC_STEPWISE"))) { - a_func = FANN_SIGMOID_SYMMETRIC_STEPWISE; - break; + _func = FANN_SIGMOID_SYMMETRIC_STEPWISE; + goto assign_function; } if (!strncmp(optarg, "FANN_SIGMOID_SYMMETRIC", strlen("FANN_SIGMOID_SYMMETRIC"))) { - a_func = FANN_SIGMOID_SYMMETRIC; - break; + _func = FANN_SIGMOID_SYMMETRIC; + goto assign_function; } if (!strncmp(optarg, "FANN_SIGMOID_STEPWISE", strlen("FANN_SIGMOID_STEPWISE"))) { - a_func = FANN_SIGMOID_STEPWISE; - break; + _func = FANN_SIGMOID_STEPWISE; + goto assign_function; } if (!strncmp(optarg, "FANN_SIGMOID", strlen("FANN_SIGMOID"))) { - a_func = FANN_SIGMOID; - break; + _func = FANN_SIGMOID; + goto assign_function; } 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; + break; case ':': case '?': usage(argv[0]); @@ -275,8 +285,8 @@ 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, a_func); - fann_set_activation_function_output(tfann, a_func); + fann_set_activation_function_hidden(tfann, h_func); + fann_set_activation_function_output(tfann, o_func); tfanndata.num_data = t_patData.numPatterns; tfanndata.num_input = t_patData.numInputUnits; tfanndata.num_output = t_patData.numOutputUnits; |