Update of /cvsroot/pure-data/externals/ann/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28233
Modified Files: ann_mlp.c ann_td.c makefile.msvc Log Message: mlp and td ready to be compiled as a single file (library) ann.c needs to be changed: we should add #include ann_*.c
Index: ann_mlp.c =================================================================== RCS file: /cvsroot/pure-data/externals/ann/src/ann_mlp.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ann_mlp.c 20 May 2005 11:06:37 -0000 1.5 --- ann_mlp.c 20 May 2005 20:53:00 -0000 1.6 *************** *** 11,16 **** #include "fann.h"
- #define VERSION "0.03" #ifndef __DATE__ #define __DATE__ "" --- 11,18 ---- #include "fann.h"
+ #ifndef VERSION + #define VERSION "0.2" + #endif
#ifndef __DATE__ #define __DATE__ "" *************** *** 37,41 **** } t_ann_mlp;
! static void help(t_ann_mlp *x) { post(""); --- 39,43 ---- } t_ann_mlp;
! static void ann_mlp_help(t_ann_mlp *x) { post(""); *************** *** 49,53 **** }
! static void createFann(t_ann_mlp *x, t_symbol *sl, int argc, t_atom *argv) { unsigned int num_input = 2; --- 51,55 ---- }
! static void ann_mlp_createFann(t_ann_mlp *x, t_symbol *sl, int argc, t_atom *argv) { unsigned int num_input = 2; *************** *** 78,82 **** if (num_input>MAXINPUT) { ! error("too many inputs, maximum allowed is %d",MAXINPUT); return; } --- 80,84 ---- if (num_input>MAXINPUT) { ! error("too many inputs, maximum allowed is MAXINPUT"); return; } *************** *** 84,88 **** if (num_output>MAXOUTPUT) { ! error("too many outputs, maximum allowed is %d", MAXOUTPUT); return; } --- 86,90 ---- if (num_output>MAXOUTPUT) { ! error("too many outputs, maximum allowed is MAXOUTPUT"); return; } *************** *** 109,113 **** }
! static void print_status(t_ann_mlp *x) { if (x->mode == TRAIN) --- 111,115 ---- }
! static void ann_mlp_print_status(t_ann_mlp *x) { if (x->mode == TRAIN) *************** *** 117,121 **** }
! static void train(t_ann_mlp *x) { x->mode=TRAIN; --- 119,123 ---- }
! static void ann_mlp_train(t_ann_mlp *x) { x->mode=TRAIN; *************** *** 126,139 **** } fann_reset_MSE(x->ann); ! print_status(x); }
! static void run(t_ann_mlp *x) { x->mode=RUN; ! print_status(x); }
! static void set_mode(t_ann_mlp *x, t_symbol *sl, int argc, t_atom *argv) { if (argc<1) --- 128,141 ---- } fann_reset_MSE(x->ann); ! ann_mlp_print_status(x); }
! static void ann_mlp_run(t_ann_mlp *x) { x->mode=RUN; ! ann_mlp_print_status(x); }
! static void ann_mlp_set_mode(t_ann_mlp *x, t_symbol *sl, int argc, t_atom *argv) { if (argc<1) *************** *** 144,148 **** { x->mode = atom_getint(argv++); ! print_status(x); } } --- 146,150 ---- { x->mode = atom_getint(argv++); ! ann_mlp_print_status(x); } } *************** *** 150,154 ****
! static void train_on_file(t_ann_mlp *x, t_symbol *sl, int argc, t_atom *argv) { if (x->ann == 0) --- 152,156 ----
! static void ann_mlp_train_on_file(t_ann_mlp *x, t_symbol *sl, int argc, t_atom *argv) { if (x->ann == 0) *************** *** 172,179 **** x->iterations_between_reports, x->desired_error); ! post("nn: finished training on file %s", x->filenametrain->s_name); }
! static void set_desired_error(t_ann_mlp *x, t_symbol *sl, int argc, t_atom *argv) { float desired_error = (float)0.001; --- 174,181 ---- x->iterations_between_reports, x->desired_error); ! post("ann_mlp: finished training on file %s", x->filenametrain->s_name); }
! static void ann_mlp_set_desired_error(t_ann_mlp *x, t_symbol *sl, int argc, t_atom *argv) { float desired_error = (float)0.001; *************** *** 189,193 **** }
! static void set_max_iterations(t_ann_mlp *x, t_symbol *sl, int argc, t_atom *argv) { unsigned int max_iterations = 500000; --- 191,195 ---- }
! static void ann_mlp_set_max_iterations(t_ann_mlp *x, t_symbol *sl, int argc, t_atom *argv) { unsigned int max_iterations = 500000; *************** *** 203,207 **** }
! static void set_iterations_between_reports(t_ann_mlp *x, t_symbol *sl, int argc, t_atom *argv) { --- 205,209 ---- }
! static void ann_mlp_set_iterations_between_reports(t_ann_mlp *x, t_symbol *sl, int argc, t_atom *argv) { *************** *** 222,226 **** // run the ann using floats in list passed to the inlet as input values // and send result to outlet as list of float ! static void run_the_net(t_ann_mlp *x, t_symbol *sl, int argc, t_atom *argv) { int i=0; --- 224,228 ---- // run the ann using floats in list passed to the inlet as input values // and send result to outlet as list of float ! static void ann_mlp_run_the_net(t_ann_mlp *x, t_symbol *sl, int argc, t_atom *argv) { int i=0; *************** *** 276,280 **** }
! static void train_on_the_fly(t_ann_mlp *x, t_symbol *sl, int argc, t_atom *argv) { int i=0; --- 278,282 ---- }
! static void ann_mlp_train_on_the_fly(t_ann_mlp *x, t_symbol *sl, int argc, t_atom *argv) { int i=0; *************** *** 335,349 **** }
! static void manage_list(t_ann_mlp *x, t_symbol *sl, int argc, t_atom *argv) { if (x->mode) ! run_the_net(x, sl, argc, argv); else { ! train_on_the_fly(x, sl, argc, argv); } }
! static void set_filename(t_ann_mlp *x, t_symbol *sl, int argc, t_atom *argv) { if (argc>0) { --- 337,351 ---- }
! static void ann_mlp_manage_list(t_ann_mlp *x, t_symbol *sl, int argc, t_atom *argv) { if (x->mode) ! ann_mlp_run_the_net(x, sl, argc, argv); else { ! ann_mlp_train_on_the_fly(x, sl, argc, argv); } }
! static void ann_mlp_set_filename(t_ann_mlp *x, t_symbol *sl, int argc, t_atom *argv) { if (argc>0) { *************** *** 356,360 **** }
! static void load_ann_from_file(t_ann_mlp *x, t_symbol *sl, int argc, t_atom *argv) { if (argc>0) { --- 358,362 ---- }
! static void ann_mlp_load_ann_from_file(t_ann_mlp *x, t_symbol *sl, int argc, t_atom *argv) { if (argc>0) { *************** *** 368,372 **** }
! static void save_ann_to_file(t_ann_mlp *x, t_symbol *sl, int argc, t_atom *argv) { if (argc>0) { --- 370,374 ---- }
! static void ann_mlp_save_ann_to_file(t_ann_mlp *x, t_symbol *sl, int argc, t_atom *argv) { if (argc>0) { *************** *** 384,388 ****
// functions for training algo: ! static void set_FANN_TRAIN_INCREMENTAL(t_ann_mlp *x) { if (x->ann == 0) --- 386,390 ----
// functions for training algo: ! static void ann_mlp_set_FANN_TRAIN_INCREMENTAL(t_ann_mlp *x) { if (x->ann == 0) *************** *** 395,399 **** } } ! static void set_FANN_TRAIN_BATCH(t_ann_mlp *x) { if (x->ann == 0) --- 397,401 ---- } } ! static void ann_mlp_set_FANN_TRAIN_BATCH(t_ann_mlp *x) { if (x->ann == 0) *************** *** 406,410 **** } } ! static void set_FANN_TRAIN_RPROP(t_ann_mlp *x) { if (x->ann == 0) --- 408,412 ---- } } ! static void ann_mlp_set_FANN_TRAIN_RPROP(t_ann_mlp *x) { if (x->ann == 0) *************** *** 417,421 **** } } ! static void set_FANN_TRAIN_QUICKPROP(t_ann_mlp *x) { if (x->ann == 0) --- 419,423 ---- } } ! static void ann_mlp_set_FANN_TRAIN_QUICKPROP(t_ann_mlp *x) { if (x->ann == 0) *************** *** 429,433 **** }
! static void set_activation_function_output(t_ann_mlp *x, t_symbol *sl, int argc, t_atom *argv) { t_symbol *parametro = 0; --- 431,435 ---- }
! static void ann_mlp_set_activation_function_output(t_ann_mlp *x, t_symbol *sl, int argc, t_atom *argv) { t_symbol *parametro = 0; *************** *** 465,489 **** }
! static void print_ann_details(t_ann_mlp *x) { if (x->ann == 0) { ! post("nn:ann is not initialized"); } else { ! post("nn:follows a description of the current ann:"); ! post("nn:num_input=%i", x->ann->num_input); ! post("nn:num_output=%i", x->ann->num_output); ! post("nn:learning_rate=%f", x->ann->learning_rate); ! post("nn:connection_rate=%f", x->ann->connection_rate); ! post("nn:total_neurons=%i", x->ann->total_neurons); ! post("nn:total_connections=%i", x->ann->total_connections); ! post("nn:last error=%i", x->ann->errstr); if (x->filename == 0) { ! post("nn:filename not set"); } else { ! post("nn:filename=%s", x->filename->s_name); } } --- 467,491 ---- }
! static void ann_mlp_print_ann_details(t_ann_mlp *x) { if (x->ann == 0) { ! post("ann_mlp:ann is not initialized"); } else { ! post("follows a description of the current ann:"); ! post("num_input=%i", x->ann->num_input); ! post("num_output=%i", x->ann->num_output); ! post("learning_rate=%f", x->ann->learning_rate); ! post("connection_rate=%f", x->ann->connection_rate); ! post("total_neurons=%i", x->ann->total_neurons); ! post("total_connections=%i", x->ann->total_connections); ! post("last error=%i", x->ann->errstr); if (x->filename == 0) { ! post("ann_mlp:filename not set"); } else { ! post("filename=%s", x->filename->s_name); } } *************** *** 491,495 ****
! static void *nn_new(t_symbol *s, int argc, t_atom *argv) { t_ann_mlp *x = (t_ann_mlp *)pd_new(ann_mlp_class); --- 493,497 ----
! static void *ann_mlp_new(t_symbol *s, int argc, t_atom *argv) { t_ann_mlp *x = (t_ann_mlp *)pd_new(ann_mlp_class); *************** *** 504,514 **** if (argc>0) { x->filename = atom_gensym(argv); ! load_ann_from_file(x, NULL , 0, NULL); } return (void *)x; }
// free resources ! static void nn_free(t_ann_mlp *x) { struct fann *ann = x->ann; --- 506,524 ---- if (argc>0) { x->filename = atom_gensym(argv); ! ann_mlp_load_ann_from_file(x, NULL , 0, NULL); } + + post(""); + post("ann_mlp: neural nets for PD"); + post("version: "VERSION""); + post("compiled: "__DATE__); + post("author: Davide Morelli"); + post("contact: info@davidemorelli.it www.davidemorelli.it"); + return (void *)x; }
// free resources ! static void ann_mlp_free(t_ann_mlp *x) { struct fann *ann = x->ann; *************** *** 519,561 **** void ann_mlp_setup(void) {
- post(""); - post("ann_mlp: neural nets for PD"); - post("version: "VERSION""); - post("compiled: "__DATE__); - post("author: Davide Morelli"); - post("contact: info@davidemorelli.it www.davidemorelli.it"); - ann_mlp_class = class_new(gensym("ann_mlp"), ! (t_newmethod)nn_new, ! (t_method)nn_free, sizeof(t_ann_mlp), CLASS_DEFAULT, A_GIMME, 0);
// general.. ! class_addmethod(ann_mlp_class, (t_method)help, gensym("help"), 0); ! class_addmethod(ann_mlp_class, (t_method)createFann, gensym("create"), A_GIMME, 0); ! class_addmethod(ann_mlp_class, (t_method)train, gensym("train"), 0); ! class_addmethod(ann_mlp_class, (t_method)run, gensym("run"), 0); ! class_addmethod(ann_mlp_class, (t_method)set_mode, gensym("setmode"), A_GIMME, 0); ! class_addmethod(ann_mlp_class, (t_method)train_on_file, gensym("train-on-file"), A_GIMME, 0); ! class_addmethod(ann_mlp_class, (t_method)manage_list, gensym("data"), A_GIMME, 0); ! class_addmethod(ann_mlp_class, (t_method)set_filename, gensym("filename"), A_GIMME, 0); ! class_addmethod(ann_mlp_class, (t_method)load_ann_from_file, gensym("load"),A_GIMME, 0); ! class_addmethod(ann_mlp_class, (t_method)save_ann_to_file, gensym("save"),A_GIMME, 0); ! class_addmethod(ann_mlp_class, (t_method)print_ann_details, gensym("details"), 0); // change training parameters ! class_addmethod(ann_mlp_class, (t_method)set_desired_error, gensym("desired_error"),A_GIMME, 0); ! class_addmethod(ann_mlp_class, (t_method)set_max_iterations, gensym("max_iterations"),A_GIMME, 0); ! class_addmethod(ann_mlp_class, (t_method)set_iterations_between_reports, gensym("iterations_between_reports"),A_GIMME, 0);
// change training and activation algorithms ! class_addmethod(ann_mlp_class, (t_method)set_FANN_TRAIN_INCREMENTAL, gensym("FANN_TRAIN_INCREMENTAL"), 0); ! class_addmethod(ann_mlp_class, (t_method)set_FANN_TRAIN_BATCH, gensym("FANN_TRAIN_BATCH"), 0); ! class_addmethod(ann_mlp_class, (t_method)set_FANN_TRAIN_RPROP, gensym("FANN_TRAIN_RPROP"), 0); ! class_addmethod(ann_mlp_class, (t_method)set_FANN_TRAIN_QUICKPROP, gensym("FANN_TRAIN_QUICKPROP"), 0); ! class_addmethod(ann_mlp_class, (t_method)set_activation_function_output, gensym("set_activation_function_output"),A_GIMME, 0); // the most important one: running the ann ! class_addlist(ann_mlp_class, (t_method)manage_list);
// help patch --- 529,564 ---- void ann_mlp_setup(void) {
ann_mlp_class = class_new(gensym("ann_mlp"), ! (t_newmethod)ann_mlp_new, ! (t_method)ann_mlp_free, sizeof(t_ann_mlp), CLASS_DEFAULT, A_GIMME, 0);
// general.. ! class_addmethod(ann_mlp_class, (t_method)ann_mlp_help, gensym("help"), 0); ! class_addmethod(ann_mlp_class, (t_method)ann_mlp_createFann, gensym("create"), A_GIMME, 0); ! class_addmethod(ann_mlp_class, (t_method)ann_mlp_train, gensym("train"), 0); ! class_addmethod(ann_mlp_class, (t_method)ann_mlp_run, gensym("run"), 0); ! class_addmethod(ann_mlp_class, (t_method)ann_mlp_set_mode, gensym("setmode"), A_GIMME, 0); ! class_addmethod(ann_mlp_class, (t_method)ann_mlp_train_on_file, gensym("train-on-file"), A_GIMME, 0); ! class_addmethod(ann_mlp_class, (t_method)ann_mlp_manage_list, gensym("data"), A_GIMME, 0); ! class_addmethod(ann_mlp_class, (t_method)ann_mlp_set_filename, gensym("filename"), A_GIMME, 0); ! class_addmethod(ann_mlp_class, (t_method)ann_mlp_load_ann_from_file, gensym("load"),A_GIMME, 0); ! class_addmethod(ann_mlp_class, (t_method)ann_mlp_save_ann_to_file, gensym("save"),A_GIMME, 0); ! class_addmethod(ann_mlp_class, (t_method)ann_mlp_print_ann_details, gensym("details"), 0); // change training parameters ! class_addmethod(ann_mlp_class, (t_method)ann_mlp_set_desired_error, gensym("desired_error"),A_GIMME, 0); ! class_addmethod(ann_mlp_class, (t_method)ann_mlp_set_max_iterations, gensym("max_iterations"),A_GIMME, 0); ! class_addmethod(ann_mlp_class, (t_method)ann_mlp_set_iterations_between_reports, gensym("iterations_between_reports"),A_GIMME, 0);
// change training and activation algorithms ! class_addmethod(ann_mlp_class, (t_method)ann_mlp_set_FANN_TRAIN_INCREMENTAL, gensym("FANN_TRAIN_INCREMENTAL"), 0); ! class_addmethod(ann_mlp_class, (t_method)ann_mlp_set_FANN_TRAIN_BATCH, gensym("FANN_TRAIN_BATCH"), 0); ! class_addmethod(ann_mlp_class, (t_method)ann_mlp_set_FANN_TRAIN_RPROP, gensym("FANN_TRAIN_RPROP"), 0); ! class_addmethod(ann_mlp_class, (t_method)ann_mlp_set_FANN_TRAIN_QUICKPROP, gensym("FANN_TRAIN_QUICKPROP"), 0); ! class_addmethod(ann_mlp_class, (t_method)ann_mlp_set_activation_function_output, gensym("set_activation_function_output"),A_GIMME, 0); // the most important one: running the ann ! class_addlist(ann_mlp_class, (t_method)ann_mlp_manage_list);
// help patch
Index: ann_td.c =================================================================== RCS file: /cvsroot/pure-data/externals/ann/src/ann_td.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ann_td.c 20 May 2005 11:06:37 -0000 1.5 --- ann_td.c 20 May 2005 20:53:00 -0000 1.6 *************** *** 11,16 **** #include "fann.h"
- #define VERSION "0.01" #ifndef __DATE__ #define __DATE__ "" --- 11,18 ---- #include "fann.h"
+ #ifndef VERSION + #define VERSION "0.2" + #endif
#ifndef __DATE__ #define __DATE__ "" *************** *** 41,45 **** } t_ann_td;
! static void help(t_ann_td *x) { post(""); --- 43,47 ---- } t_ann_td;
! static void ann_td_help(t_ann_td *x) { post(""); *************** *** 53,57 **** }
! static void deallocate_inputs(t_ann_td *x) { if (x->inputs != 0) --- 55,59 ---- }
! static void ann_td_deallocate_inputs(t_ann_td *x) { if (x->inputs != 0) *************** *** 62,69 **** }
! static void allocate_inputs(t_ann_td *x) { unsigned int i; ! deallocate_inputs(x); // allocate space for inputs array x->inputs = (t_float *)getbytes((x->frames) * (x->num_input) * sizeof(t_float)); --- 64,71 ---- }
! static void ann_td_allocate_inputs(t_ann_td *x) { unsigned int i; ! ann_td_deallocate_inputs(x); // allocate space for inputs array x->inputs = (t_float *)getbytes((x->frames) * (x->num_input) * sizeof(t_float)); *************** *** 71,75 **** }
! static void createFann(t_ann_td *x, t_symbol *sl, int argc, t_atom *argv) { unsigned int num_input = 2; --- 73,77 ---- }
! static void ann_td_createFann(t_ann_td *x, t_symbol *sl, int argc, t_atom *argv) { unsigned int num_input = 2; *************** *** 127,131 **** fann_set_activation_function_output(x->ann, FANN_SIGMOID_SYMMETRIC);
! allocate_inputs(x);
if (x->ann == 0) --- 129,133 ---- fann_set_activation_function_output(x->ann, FANN_SIGMOID_SYMMETRIC);
! ann_td_allocate_inputs(x);
if (x->ann == 0) *************** *** 145,149 **** }
! static void print_status(t_ann_td *x) { if (x->mode == TRAIN) --- 147,151 ---- }
! static void ann_td_print_status(t_ann_td *x) { if (x->mode == TRAIN) *************** *** 153,157 **** }
! static void train(t_ann_td *x) { x->mode=TRAIN; --- 155,159 ---- }
! static void ann_td_train(t_ann_td *x) { x->mode=TRAIN; *************** *** 162,175 **** } fann_reset_MSE(x->ann); ! print_status(x); }
! static void run(t_ann_td *x) { x->mode=RUN; ! print_status(x); }
! static void set_mode(t_ann_td *x, t_symbol *sl, int argc, t_atom *argv) { if (argc<1) --- 164,177 ---- } fann_reset_MSE(x->ann); ! ann_td_print_status(x); }
! static void ann_td_run(t_ann_td *x) { x->mode=RUN; ! ann_td_print_status(x); }
! static void ann_td_set_mode(t_ann_td *x, t_symbol *sl, int argc, t_atom *argv) { if (argc<1) *************** *** 180,184 **** { x->mode = atom_getint(argv++); ! print_status(x); } } --- 182,186 ---- { x->mode = atom_getint(argv++); ! ann_td_print_status(x); } } *************** *** 186,190 ****
! static void train_on_file(t_ann_td *x, t_symbol *sl, int argc, t_atom *argv) { if (x->ann == 0) --- 188,192 ----
! static void ann_td_train_on_file(t_ann_td *x, t_symbol *sl, int argc, t_atom *argv) { if (x->ann == 0) *************** *** 211,215 **** }
! static void set_desired_error(t_ann_td *x, t_symbol *sl, int argc, t_atom *argv) { float desired_error = (float)0.001; --- 213,217 ---- }
! static void ann_td_set_desired_error(t_ann_td *x, t_symbol *sl, int argc, t_atom *argv) { float desired_error = (float)0.001; *************** *** 225,229 **** }
! static void set_max_iterations(t_ann_td *x, t_symbol *sl, int argc, t_atom *argv) { unsigned int max_iterations = 500000; --- 227,231 ---- }
! static void ann_td_set_max_iterations(t_ann_td *x, t_symbol *sl, int argc, t_atom *argv) { unsigned int max_iterations = 500000; *************** *** 239,243 **** }
! static void set_iterations_between_reports(t_ann_td *x, t_symbol *sl, int argc, t_atom *argv) { --- 241,245 ---- }
! static void ann_td_set_iterations_between_reports(t_ann_td *x, t_symbol *sl, int argc, t_atom *argv) { *************** *** 256,260 ****
! static void scale_inputs(t_ann_td *x) { unsigned int j; --- 258,262 ----
! static void ann_td_scale_inputs(t_ann_td *x) { unsigned int j; *************** *** 274,278 **** // run the ann using floats in list passed to the inlet as input values // and send result to outlet as list of float ! static void run_the_net(t_ann_td *x, t_symbol *sl, int argc, t_atom *argv) { int i=0; --- 276,280 ---- // run the ann using floats in list passed to the inlet as input values // and send result to outlet as list of float ! static void ann_td_run_the_net(t_ann_td *x, t_symbol *sl, int argc, t_atom *argv) { int i=0; *************** *** 303,307 **** quanti = x->ann->num_output;
! scale_inputs(x);
// fill output array with zeros --- 305,309 ---- quanti = x->ann->num_output;
! ann_td_scale_inputs(x);
// fill output array with zeros *************** *** 338,342 **** }
! static void train_on_the_fly(t_ann_td *x, t_symbol *sl, int argc, t_atom *argv) { int i=0; --- 340,344 ---- }
! static void ann_td_train_on_the_fly(t_ann_td *x, t_symbol *sl, int argc, t_atom *argv) { int i=0; *************** *** 371,375 **** }
! scale_inputs(x);
// fill input array with actual data sent to inlet --- 373,377 ---- }
! ann_td_scale_inputs(x);
// fill input array with actual data sent to inlet *************** *** 399,413 **** }
! static void manage_list(t_ann_td *x, t_symbol *sl, int argc, t_atom *argv) { if (x->mode) ! run_the_net(x, sl, argc, argv); else { ! train_on_the_fly(x, sl, argc, argv); } }
! static void set_filename(t_ann_td *x, t_symbol *sl, int argc, t_atom *argv) { if (argc>0) { --- 401,415 ---- }
! static void ann_td_manage_list(t_ann_td *x, t_symbol *sl, int argc, t_atom *argv) { if (x->mode) ! ann_td_run_the_net(x, sl, argc, argv); else { ! ann_td_train_on_the_fly(x, sl, argc, argv); } }
! static void ann_td_set_filename(t_ann_td *x, t_symbol *sl, int argc, t_atom *argv) { if (argc>0) { *************** *** 420,424 **** }
! static void load_ann_from_file(t_ann_td *x, t_symbol *sl, int argc, t_atom *argv) { if (x->ins_frames_set==0) --- 422,426 ---- }
! static void ann_td_load_ann_from_file(t_ann_td *x, t_symbol *sl, int argc, t_atom *argv) { if (x->ins_frames_set==0) *************** *** 437,444 **** post("nn:ann loaded fom file %s", x->filename->s_name); ! allocate_inputs(x); }
! static void save_ann_to_file(t_ann_td *x, t_symbol *sl, int argc, t_atom *argv) { if (argc>0) { --- 439,446 ---- post("nn:ann loaded fom file %s", x->filename->s_name); ! ann_td_allocate_inputs(x); }
! static void ann_td_save_ann_to_file(t_ann_td *x, t_symbol *sl, int argc, t_atom *argv) { if (argc>0) { *************** *** 456,460 ****
// functions for training algo: ! static void set_FANN_TRAIN_INCREMENTAL(t_ann_td *x) { if (x->ann == 0) --- 458,462 ----
// functions for training algo: ! static void ann_td_set_FANN_TRAIN_INCREMENTAL(t_ann_td *x) { if (x->ann == 0) *************** *** 467,471 **** } } ! static void set_FANN_TRAIN_BATCH(t_ann_td *x) { if (x->ann == 0) --- 469,473 ---- } } ! static void ann_td_set_FANN_TRAIN_BATCH(t_ann_td *x) { if (x->ann == 0) *************** *** 478,482 **** } } ! static void set_FANN_TRAIN_RPROP(t_ann_td *x) { if (x->ann == 0) --- 480,484 ---- } } ! static void ann_td_set_FANN_TRAIN_RPROP(t_ann_td *x) { if (x->ann == 0) *************** *** 489,493 **** } } ! static void set_FANN_TRAIN_QUICKPROP(t_ann_td *x) { if (x->ann == 0) --- 491,495 ---- } } ! static void ann_td_set_FANN_TRAIN_QUICKPROP(t_ann_td *x) { if (x->ann == 0) *************** *** 501,505 **** }
! static void set_activation_function_output(t_ann_td *x, t_symbol *sl, int argc, t_atom *argv) { t_symbol *parametro = 0; --- 503,507 ---- }
! static void ann_td_set_activation_function_output(t_ann_td *x, t_symbol *sl, int argc, t_atom *argv) { t_symbol *parametro = 0; *************** *** 537,541 **** }
! static void print_ann_details(t_ann_td *x) { if (x->ann == 0) --- 539,543 ---- }
! static void ann_td_print_ann_details(t_ann_td *x) { if (x->ann == 0) *************** *** 562,566 **** }
! static void set_num_input_frames(t_ann_td *x, t_floatarg ins, t_floatarg frames) { x->num_input = ins; --- 564,568 ---- }
! static void ann_td_set_num_input_frames(t_ann_td *x, t_floatarg ins, t_floatarg frames) { x->num_input = ins; *************** *** 569,573 **** }
! static void *nn_new(t_symbol *s, int argc, t_atom *argv) { t_ann_td *x = (t_ann_td *)pd_new(ann_td_class); --- 571,575 ---- }
! static void *ann_td_new(t_symbol *s, int argc, t_atom *argv) { t_ann_td *x = (t_ann_td *)pd_new(ann_td_class); *************** *** 594,614 **** x->frames = atom_getint(argv++); x->ins_frames_set=1; ! allocate_inputs(x); }
if (argc>2) { x->filename = atom_gensym(argv); ! load_ann_from_file(x, NULL , 0, NULL); }
return (void *)x; }
// free resources ! static void nn_free(t_ann_td *x) { struct fann *ann = x->ann; fann_destroy(ann); ! deallocate_inputs(x); // TODO: free other resources! } --- 596,623 ---- x->frames = atom_getint(argv++); x->ins_frames_set=1; ! ann_td_allocate_inputs(x); }
if (argc>2) { x->filename = atom_gensym(argv); ! ann_td_load_ann_from_file(x, NULL , 0, NULL); }
+ post(""); + post("ann_td: time delay neural nets for PD"); + post("version: "VERSION""); + post("compiled: "__DATE__); + post("author: Davide Morelli"); + post("contact: info@davidemorelli.it www.davidemorelli.it"); + return (void *)x; }
// free resources ! static void ann_td_free(t_ann_td *x) { struct fann *ann = x->ann; fann_destroy(ann); ! ann_td_deallocate_inputs(x); // TODO: free other resources! } *************** *** 616,660 **** void ann_td_setup(void) {
- post(""); - post("ann_td: time delay neural nets for PD"); - post("version: "VERSION""); - post("compiled: "__DATE__); - post("author: Davide Morelli"); - post("contact: info@davidemorelli.it www.davidemorelli.it"); - ann_td_class = class_new(gensym("ann_td"), ! (t_newmethod)nn_new, ! (t_method)nn_free, sizeof(t_ann_td), CLASS_DEFAULT, A_GIMME, 0);
// general.. ! class_addmethod(ann_td_class, (t_method)help, gensym("help"), 0); ! class_addmethod(ann_td_class, (t_method)createFann, gensym("create"), A_GIMME, 0); ! class_addmethod(ann_td_class, (t_method)train, gensym("train"), 0); ! class_addmethod(ann_td_class, (t_method)run, gensym("run"), 0); ! class_addmethod(ann_td_class, (t_method)set_mode, gensym("setmode"), A_GIMME, 0); ! class_addmethod(ann_td_class, (t_method)train_on_file, gensym("train-on-file"), A_GIMME, 0); ! class_addmethod(ann_td_class, (t_method)manage_list, gensym("data"), A_GIMME, 0); ! class_addmethod(ann_td_class, (t_method)set_filename, gensym("filename"), A_GIMME, 0); ! class_addmethod(ann_td_class, (t_method)load_ann_from_file, gensym("load"),A_GIMME, 0); ! class_addmethod(ann_td_class, (t_method)save_ann_to_file, gensym("save"),A_GIMME, 0); ! class_addmethod(ann_td_class, (t_method)print_ann_details, gensym("details"), 0); // change training parameters ! class_addmethod(ann_td_class, (t_method)set_desired_error, gensym("desired_error"),A_GIMME, 0); ! class_addmethod(ann_td_class, (t_method)set_max_iterations, gensym("max_iterations"),A_GIMME, 0); ! class_addmethod(ann_td_class, (t_method)set_iterations_between_reports, gensym("iterations_between_reports"),A_GIMME, 0);
// change training and activation algorithms ! class_addmethod(ann_td_class, (t_method)set_FANN_TRAIN_INCREMENTAL, gensym("FANN_TRAIN_INCREMENTAL"), 0); ! class_addmethod(ann_td_class, (t_method)set_FANN_TRAIN_BATCH, gensym("FANN_TRAIN_BATCH"), 0); ! class_addmethod(ann_td_class, (t_method)set_FANN_TRAIN_RPROP, gensym("FANN_TRAIN_RPROP"), 0); ! class_addmethod(ann_td_class, (t_method)set_FANN_TRAIN_QUICKPROP, gensym("FANN_TRAIN_QUICKPROP"), 0); ! class_addmethod(ann_td_class, (t_method)set_activation_function_output, gensym("set_activation_function_output"),A_GIMME, 0); ! class_addmethod(ann_td_class, (t_method)set_num_input_frames, gensym("inputs_frames"),A_DEFFLOAT, A_DEFFLOAT, 0); // the most important one: running the ann ! class_addlist(ann_td_class, (t_method)manage_list);
// help patch --- 625,662 ---- void ann_td_setup(void) {
ann_td_class = class_new(gensym("ann_td"), ! (t_newmethod)ann_td_new, ! (t_method)ann_td_free, sizeof(t_ann_td), CLASS_DEFAULT, A_GIMME, 0);
// general.. ! class_addmethod(ann_td_class, (t_method)ann_td_help, gensym("help"), 0); ! class_addmethod(ann_td_class, (t_method)ann_td_createFann, gensym("create"), A_GIMME, 0); ! class_addmethod(ann_td_class, (t_method)ann_td_train, gensym("train"), 0); ! class_addmethod(ann_td_class, (t_method)ann_td_run, gensym("run"), 0); ! class_addmethod(ann_td_class, (t_method)ann_td_set_mode, gensym("setmode"), A_GIMME, 0); ! class_addmethod(ann_td_class, (t_method)ann_td_train_on_file, gensym("train-on-file"), A_GIMME, 0); ! class_addmethod(ann_td_class, (t_method)ann_td_manage_list, gensym("data"), A_GIMME, 0); ! class_addmethod(ann_td_class, (t_method)ann_td_set_filename, gensym("filename"), A_GIMME, 0); ! class_addmethod(ann_td_class, (t_method)ann_td_load_ann_from_file, gensym("load"),A_GIMME, 0); ! class_addmethod(ann_td_class, (t_method)ann_td_save_ann_to_file, gensym("save"),A_GIMME, 0); ! class_addmethod(ann_td_class, (t_method)ann_td_print_ann_details, gensym("details"), 0); // change training parameters ! class_addmethod(ann_td_class, (t_method)ann_td_set_desired_error, gensym("desired_error"),A_GIMME, 0); ! class_addmethod(ann_td_class, (t_method)ann_td_set_max_iterations, gensym("max_iterations"),A_GIMME, 0); ! class_addmethod(ann_td_class, (t_method)ann_td_set_iterations_between_reports, gensym("iterations_between_reports"),A_GIMME, 0);
// change training and activation algorithms ! class_addmethod(ann_td_class, (t_method)ann_td_set_FANN_TRAIN_INCREMENTAL, gensym("FANN_TRAIN_INCREMENTAL"), 0); ! class_addmethod(ann_td_class, (t_method)ann_td_set_FANN_TRAIN_BATCH, gensym("FANN_TRAIN_BATCH"), 0); ! class_addmethod(ann_td_class, (t_method)ann_td_set_FANN_TRAIN_RPROP, gensym("FANN_TRAIN_RPROP"), 0); ! class_addmethod(ann_td_class, (t_method)ann_td_set_FANN_TRAIN_QUICKPROP, gensym("FANN_TRAIN_QUICKPROP"), 0); ! class_addmethod(ann_td_class, (t_method)ann_td_set_activation_function_output, gensym("set_activation_function_output"),A_GIMME, 0); ! class_addmethod(ann_td_class, (t_method)ann_td_set_num_input_frames, gensym("inputs_frames"),A_DEFFLOAT, A_DEFFLOAT, 0); // the most important one: running the ann ! class_addlist(ann_td_class, (t_method)ann_td_manage_list);
// help patch
Index: makefile.msvc =================================================================== RCS file: /cvsroot/pure-data/externals/ann/src/makefile.msvc,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** makefile.msvc 19 May 2005 15:04:33 -0000 1.3 --- makefile.msvc 20 May 2005 20:53:00 -0000 1.4 *************** *** 12,18 ****
! current: clean pd_nt
- pd_nt: ann_som.dll ann_mlp.dll ann_td.dll
.SUFFIXES: .dll --- 12,20 ----
! current: clean pd_nt distclean ! ! pd_nt: ann_som.dll ann_mlp.dll ann_td.dll ann.dll ! #pd_nt: ann.dll
.SUFFIXES: .dll *************** *** 28,39 **** $(PDNTLDIR)\kernel32.lib \ $(PDPATH)\bin\pd.lib \ ! $(FANNLIB)\libfann.lib
.c.dll: cl $(PDNTCFLAGS) $(PDNTINCLUDE) /c $*.c ! link /dll /export:$*_setup $*.obj $(PDNTLIB) ! -del *.obj ! -del *.lib ! -del *.exp
#install: --- 30,42 ---- $(PDNTLDIR)\kernel32.lib \ $(PDPATH)\bin\pd.lib \ ! $(FANNLIB)\libfann.lib ! # ann_mlp.lib ann_som.lib ann_td.lib
.c.dll: cl $(PDNTCFLAGS) $(PDNTINCLUDE) /c $*.c ! link /dll /export:$*_setup $*.obj $(PDNTLIB) *.lib ! # -del *.obj ! # -del *.lib ! # -del *.exp
#install: *************** *** 47,48 **** --- 50,55 ---- -del *.dll
+ distclean: + -del *.obj + -del *.lib + -del *.exp