How to use the exported TMultiLayerPerceptron weights in a new root script?

Hi folks,

newbie here with the ANNs. I have the following question: I wrote a root script, where I use TMultiLayerPerceptron to create a NN, which I train with a set of data, I export the weights (via mlp->Export(“my_nn_weights”)) and I check within that first script via
mlp->Evaluate(0,params) that the output makes sense.

Now, in order to use that NN, in particular the mlp->Evaluate() in another root script, I try to define therein a new TMultiLayerPerceptron and load the previously saved weights.
I see that to get it working is not as simple as calling the default constructor and using load, e.g. something like:
TMultiLayerPerceptron *mlp = new TMultiLayerPerceptron();

However, defining again the same TMultiLayerPerceptron with the same input and ouput variables, nn structure and the tree does not work either.

The typical Higgs example and so on only use the mlp->Evaluate(0,par) within the main original root script…

Any advice or useful example?

Many thanks in advance,

Hello, all right this was my mistake with a wrong input at the second stage/ script. It is working now. If this is useful for anybody, I got it working in two ways:

  1. in the first script I save the MLP inside a ROOT file, which I then later read in the second script and directly use the mlp->Evaluate() method
  2. exporting the text-file with the weights, I load it in the second stage after having defined the same tree and NN structure as in the first script.
    Both things seem to work well.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.