Skip to content

Commit

Permalink
Fixed initialization issue for multiple runs in brainfuse_lib.c
Browse files Browse the repository at this point in the history
  • Loading branch information
orso82 committed Jun 7, 2017
1 parent 7859850 commit 59054b9
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 11 deletions.
19 changes: 8 additions & 11 deletions brainfuse_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <dirent.h>

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
Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
}
Expand Down
74 changes: 74 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -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 [email protected]:libfann/fann.git
cd fann
cmake .
make

Set in your .login file:

setenv FANN_ROOT loation_where_fann_was_cloned

Run `./compile.sh` script

0 comments on commit 59054b9

Please sign in to comment.