From 59054b942b842b7fc15224e1100eda6026685302 Mon Sep 17 00:00:00 2001 From: Orso Meneghini Date: Tue, 6 Jun 2017 22:19:53 -0700 Subject: [PATCH] Fixed initialization issue for multiple runs in brainfuse_lib.c --- brainfuse_lib.c | 19 ++++++------- readme.md | 74 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+), 11 deletions(-) create mode 100644 readme.md diff --git a/brainfuse_lib.c b/brainfuse_lib.c index 2b22050..a414ff0 100644 --- a/brainfuse_lib.c +++ b/brainfuse_lib.c @@ -7,7 +7,7 @@ #include static unsigned int n_models=2; //number of nn physics models -static unsigned int verbose=0; +static unsigned int verbose=0; //verbose output // arrays of pointers storing multiple ANNS instances, // of multiple ANNS ensembles, for different physics models @@ -129,16 +129,6 @@ int load_anns(int global_nn_model, char *directory, char *basename){ loaded_anns[model]=1; } - // Initialize memory - for(j = 0; j < anns[model][0]->num_input; j++){ - data_avg[model]->input[0][j]=0.; - data_std[model]->input[0][j]=0.; - } - for(j = 0; j < anns[model][0]->num_output; j++){ - data_avg[model]->output[0][j]=0.; - data_std[model]->output[0][j]=0.; - } - return n; } @@ -156,12 +146,19 @@ int load_anns__(int *global_nn_model, char *directory, char *basename){ int load_anns_inputs(fann_type *data_in){ unsigned int j; if (verbose) printf("Reading ANNs input data %d inputs %d ouputs\n", anns[model][0]->num_input, anns[model][0]->num_output); + // load inputs for(j = 0; j < anns[model][0]->num_input; j++){ if (verbose) printf("in %02d: %3.3f\n",j+1,data_in[j]); data_avg[model]->input[0][j]=(fann_type)data_in[j]; data_std[model]->input[0][j]=data_avg[model]->input[0][j]; data_nrm[model]->input[0][j]=data_avg[model]->input[0][j]; } + // Initialize outputs to zero + for(j = 0; j < anns[model][0]->num_output; j++){ + data_avg[model]->output[0][j]=0.; + data_std[model]->output[0][j]=0.; + data_nrm[model]->output[0][j]=0.; + } if (verbose) printf("\n"); return 0; } diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..cf88689 --- /dev/null +++ b/readme.md @@ -0,0 +1,74 @@ +EPED1NN +======= + +There are different scripts to run the EPED1-NN model + +Low level +--------- +at the lowest level one can call the `brainfuse_run.exe` binary and pass the list +of NN files (generally called brainfuse_XX.net) and an input file. For example: + + cd eped1nn/samples + ../../brainfuse_run.exe ../models/EPED1_H_superH input_sample.dat + +here `EPED1_H_superH` is one of the models under the `models` directory + +The `input_sample.dat` has the format of: + + N1 + i1 i2 i3 i4 i5 i6 i7 i8 i9 + i1 i2 i3 i4 i5 i6 i7 i8 i9 + ... + +where: + + N1 number of runs + i.. inputs (N1 lines) + +Upon run the `output.dat` and `output.std` files will be generated in the +current working directory with the EPED1NN prediction and its standard deviation. +Both files have format: + + N1 + o1 o2 o3 o4 + o1 o2 o3 o4 + ... + +where:: + + N1 number of runs + o.. outputs (N1 lines) + +Python wrapper +-------------- +The `eped1nn` Python script wraps the `brainfuse_run.exe` executable. +This Python script also generates a `epednn.profiles` file. + + cd eped1nn/samples + ../eped1nn EPED1_H_superH input_sample.dat + + +Snyder EPED1 interface +---------------------- +The `eped1nn_eped1` Python script mimics the I/O of Phil Snyder original IDL EPED1 worflow. +The format of the input is for example in `eped1nn/samples/2015check.txt`. + + cd eped1nn/samples + ../eped1nn_eped1 EPED1_H_superH 2015check.txt + +The output of the eped1nn_eped1 will append `out` to the input filename: `eped1nn/samples/2015check_out.txt` + +Installation +------------ +Install the FANN library: + + git clone git@github.com:libfann/fann.git + cd fann + cmake . + make + +Set in your .login file: + + setenv FANN_ROOT loation_where_fann_was_cloned + +Run `./compile.sh` script