|
From: Herton R. K. <he...@us...> - 2005-06-23 20:58:47
|
Update of /cvsroot/kimageprocess/kimageprocess/testclass In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24132 Modified Files: testclass.c Log Message: - Added support for select activation functions for hidden&output neurons. Index: testclass.c =================================================================== RCS file: /cvsroot/kimageprocess/kimageprocess/testclass/testclass.c,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- testclass.c 8 Apr 2005 01:16:48 -0000 1.16 +++ testclass.c 23 Jun 2005 20:58:37 -0000 1.17 @@ -33,9 +33,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, "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"); exit(1); } @@ -173,6 +180,7 @@ {"train-pattern", 1, NULL, 't'}, {"classify-pattern", 1, NULL, 'c'}, {"res-file", 1, NULL, 'r'}, + {"activation-function", NULL, 'a'}, {0, 0, 0, 0} }; opterr = 0; @@ -185,7 +193,7 @@ float connection_rate = 1; float learning_rate = 0.7; float *result; - int npat; + int npat, a_func; time_t tempTime; if (argc == 1) @@ -194,9 +202,10 @@ t_file = NULL; c_file = NULL; r_file = NULL; + a_func = FANN_SIGMOID_SYMMETRIC_STEPWISE; while (1) { - c = getopt_long (argc, argv, "+t:c:r:", long_options, &option_index); + c = getopt_long (argc, argv, "+t:c:r:a:", long_options, &option_index); if (c == -1 && optind != argc) usage(argv[0]); if (c == -1) @@ -212,6 +221,38 @@ case 'r': r_file = optarg; break; + case 'a': + if (!strncmp(optarg, "FANN_THRESHOLD_SYMMETRIC", strlen("FANN_THRESHOLD_SYMMETRIC"))) { + a_func = FANN_THRESHOLD_SYMMETRIC; + break; + } + if (!strncmp(optarg, "FANN_THRESHOLD", strlen("FANN_THRESHOLD"))) { + a_func = FANN_THRESHOLD; + break; + } + if (!strncmp(optarg, "FANN_LINEAR", strlen("FANN_LINEAR"))) { + a_func = FANN_LINEAR; + break; + } + if (!strncmp(optarg, "FANN_SIGMOID_SYMMETRIC_STEPWISE", + strlen("FANN_SIGMOID_SYMMETRIC_STEPWISE"))) { + a_func = FANN_SIGMOID_SYMMETRIC_STEPWISE; + break; + } + if (!strncmp(optarg, "FANN_SIGMOID_SYMMETRIC", strlen("FANN_SIGMOID_SYMMETRIC"))) { + a_func = FANN_SIGMOID_SYMMETRIC; + break; + } + if (!strncmp(optarg, "FANN_SIGMOID_STEPWISE", strlen("FANN_SIGMOID_STEPWISE"))) { + a_func = FANN_SIGMOID_STEPWISE; + break; + } + if (!strncmp(optarg, "FANN_SIGMOID", strlen("FANN_SIGMOID"))) { + a_func = FANN_SIGMOID; + break; + } + usage(argv[0]); + break; case ':': case '?': usage(argv[0]); @@ -240,8 +281,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, FANN_SIGMOID_SYMMETRIC_STEPWISE); - fann_set_activation_function_output(tfann, FANN_SIGMOID_SYMMETRIC_STEPWISE); + fann_set_activation_function_hidden(tfann, a_func); + fann_set_activation_function_output(tfann, a_func); tfanndata.num_data = t_patData.numPatterns; tfanndata.num_input = t_patData.numInputUnits; tfanndata.num_output = t_patData.numOutputUnits; @@ -318,3 +359,7 @@ fatal(errno); return 0; } + +/* + * vim:noet + */ |