Application of TMultiLayerPerceptron

Hi,

I am using TMultiLayerPerceptron to do the neural network training and
testing. However I have trouble using the output of neural network.
Let me a bit more specific. First, all the neural network is trained
successfully, I dumped the weights to a file. In principle, I have the
neural network, right? Then I load weights and I should be able to use the
neural network. I have a sample script as an attachment.

Thanks for any help.

Ming

{
gROOT->Reset();

if (!gROOT->GetClass(“TMultiLayerPerceptron”)) {
gSystem->Load(“libMLP”);
}

Float_t lPstar1(0.0), lPstar2(0.0), outNN(0.0);
Float_t lPmiss(0.0), lEtotal(0.0), lAngle(0.0);
Int_t chargeL1(0), chargeL2(0), type(0);

TFile in(“input.root”);
obc->SetBranchAddress(“lPstar1” , &lPstar1 ) ; // obc is one of the trees in the root file
obc->SetBranchAddress(“lPstar2” , &lPstar2 ) ;
obc->SetBranchAddress(“lAngle” , &lAngle ) ;
obc->SetBranchAddress(“lPmiss” , &lPmiss ) ;
obc->SetBranchAddress(“lEtotal” , &lEtotal ) ;
TBranch * outNNBranch = obc->Branch(“outNN”, &outNN, “outNN/F”);

TMultiLayerPerceptron *mlp = new TMultiLayerPerceptron(“lPstar1,lPstar2,lAngle,lPmiss,lEtotal:5:outNN”,obc);
mlp->LoadWeights(“weights.txt”);

Float_t params[5];
for (Int_t i = 0; i < obc->GetEntries(); i++) {
obc->GetEntry(i);
params[0] = lPstar1;
params[1] = lPstar2;
params[2] = lAngle;
params[3] = lPmiss;
params[4] = lEtotal;
outNN = mlp->Evaluate(0,params);
outNNBranch->Fill();
}

}

Hi,

On Thursday 15 April 2004 19:52, you wrote:

Hi Christophe,

I am using TMultiLayerPerceptron to do the neural network training and
testing. However I have trouble using the output of neural network.
Let me a bit more specific. First, all the neural network is trained
successfully, I dumped the weights to a file. In principle, I have the
neural network, right?
Exactly…
Then I load weights and I should be able to use the
neural network.
Yes.
I have a sample script as an attachment. Please have a
look and let me know if anything I am doing wrong there. Thanks.
This looks fine. What’s your problem exactly ?
Have you checked that the tree is well loaded and that the NN produces nice
values ?
I cannot test your script without your TFile and your weights, but I have
attached a modified version of the mlpHiggs.C tutorial that dumps the NN to a
file, read it back to a new NN and plots the output. It works nicely.

Christophe.
mlpHiggs.C (3.83 KB)