[ROOT] TMultiLayerPerceptron

From: Krzysztof Syryczynski (ksyrycz@fuw.edu.pl)
Date: Fri Apr 02 2004 - 15:37:25 MEST


Red Hat 7 root 3.10.1 CINT/ROOT C/C++ 5.15.105

Hello

It seems that creation of TMultiLayerPerceptron does something to the tree
or I don't know  how to use it.

TMultiLayerPerceptron "mlp1" works fine with tree "aaa". 
After using "mlp1", I'd like to remove data from tree "aaa" 
and fill it gain. 
How to do it properly?

Please test the following script "test.C"
Result depends on creation of mlp1 and/or mlp2. 
Existance of another tree "BBB" is not the reason.
All lines with "BBB" can be removed. 

Cheers
Krzysztof Syryczynski


void test()
{
  gROOT->Reset();
  gDirectory->GetList()->Delete();
  if (!gROOT->GetClass("TMultiLayerPerceptron")) gSystem->Load("libMLP");

  Int_t type;
  Float_t x;
  TTree *aaa = new TTree("aaa", "aaa Events");
  aaa->Branch("x",    &x,    "x/F");
  aaa->Branch("type", &type, "type/I");

  TTree *BBB = new TTree("BBB", "BBB Events");
  BBB->Branch("x",    &x,    "x/F");
  BBB->Branch("type", &type, "type/I");

  Long_t i;
  for (i = 0; i < 1000; i++) {
    x=sin(i);
    if (x>0.5) type = 1;
    else       type = 0;
    aaa->Fill();
  }

  //creation of multiperceptron does something to the tree
  TMultiLayerPerceptron *mlp1 = new TMultiLayerPerceptron("x/F:30:type/I",aaa);

//TMultiLayerPerceptron *mlp2 = new 
//TMultiLayerPerceptron("x/F:30:type/I",BBB);

  aaa->Reset();
  BBB->Reset();
  for (i = 0; i < 10; i++) {
    x=i;
    type=i % 2;
    aaa->Fill();
    BBB->Fill();
  }
  cout<<"I expect `aaa' and `BBB' to be identical now:"<<endl;
  cout<<"  aaa->GetEntries()="<< aaa->GetEntries();
  cout<<"  BBB->GetEntries()="<< BBB->GetEntries()
  cout<<endl;
  for (i = 0; i < 10; i++) {
    aaa->GetEntry(i);
    cout<<"  aaa"<<" x["<<i<<"]="<<x<<" type["<<i<<"]="<<type;
    BBB->GetEntry(i);
    cout<<"  BBB"<<" x["<<i<<"]="<<x<<" type["<<i<<"]="<<type;
    cout<<endl;
  }
}



This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:07 MET