36. Appendix K: Neural Network Batch Training Program

36.1 K.1 Introduction:

To make the program more robust, and to take more advantage of computer resources, this program was written. This program has no user interface requirements, and thus may be run in the background. The program will load a default, or specified neural network first. The program will then decided if it can load a training set of trajectories, or if it has to generate the training set from endpoints. After the training set is ready, the net will be trained, and saved on disk.

This program may also be used as an example of how modular the program is, in general. The functions are all readily available through the limited set of function calls.

 

/*

* BATCH NEURAL NETWORK TRAINING PROGRAM

*

* This program was written to allow the neural network training to be done

* on a computer with no user interface running. The program loads a

* neural network file specified on the command line, and uses the built

* in defaults to do training. The trained network is then saved, and the

* program exits.

*

* Time can be saved by building a training set first, and saving it in

* a file (with the user interface). When the net is saved, before training,

* ensure that the from file toggle is set. This will load the training data

* directly from the file, and not cause it to be regenerated when this

* program is run. This almost essential when using optimal paths.

*

* December 3rd, 1990.

*/

 

#define TRUE 1 /* Some much needed defaults */

#define FALSE 0

 

#include "rt_def.c" /* Header files containing only */

#include "rt_dyn.c" /* needed subroutines */

#include "rt_net.c"

#include "rt_fun.c"

 

 

char net_name[] = {"test.net"}, /* default network definition file name */

rt_name[] = {"test.rt"}; /* path endpoint file name */

 

 

main(argc, argv)

int argc;

char *argv[];

/*

* EXECUTIVE SUBROUTINE

*

* This is where the setup and training occurs, as was described above. Note

* that the command line arguments are used to replace the default file

* names.

*

* December 3rd, 1990.

*/

{

static int i; /* A work variable */

 

/* batch_mode = 1; */ /* This will let the program print */

/* training messages. this should */

/* be set for any batch mode */

/* operation. */

 

init_inverse_dynamics(); /* initialize dynamics */

 

if(argc > 1){ /* if any file name specified */

/*

* add extensions to file names

*/

sprintf(net_name, "%s.net", argv[1]);

sprintf(rt_name, "%s.rt", argv[1]);

}

 

nt_load(net_name); /* load neural network file */

 

/*

* If the training data may be loaded from a file, then load it,

* if not then build a new set of training data.

*/

if(t_number == SET_FILE){

printf("training with set file\n");

b_tload(t_file, 0, &end_train); /* load trajectories */

} else {

printf("building training set\n");

b_load(rt_name); /* load endpoints */

nt_build(); /* build training set */

}

printf("\nDone...\n\nTraining.....\n");

nt_train(); /* train neural network */

nt_save(net_name); /* save trained network */

}