RE: Troubling running TMultiLayerPerceptron with ROOT 5.08/00

From: Nick West <n.west1_at_physics.ox.ac.uk>
Date: Fri, 17 Mar 2006 06:58:59 -0000


Hi Christophe,

We dug a bit deeper and finally figured why our code ran fine under 4.04/02 but failed catastrophically under any version of 5. It's not a bug in your code but in our constructor. Can you see what's wrong:-

  new TMultiLayerPerceptron("@trkPHperPlane, @eventPlanes, @shwPHperStrip:5:type",

                            inTree, 
                            "Entry$%5",
                            "!(Entry$%5)");
 

Well, did you spot it?

It is the space, added to improve readability, after each comma in the layout. The trouble is that the code in

  void TMultiLayerPerceptron::AttachData()

parses the TString (in input):-

   Int_t end = input.Index(",", beg + 1);    Int_t nentries = fFirstLayer.GetEntriesFast();    for (j=0;j<nentries;j++) {

      end = (end == -1 ? input.Length() : end);
      normalize = false;
      brName = TString(input(beg, end - beg));
      neuron = (TNeuron *) fFirstLayer.UncheckedAt(j);
      if (brName[0]=='@')
         normalize = true;
...
      beg = end + 1;
      end = input.Index(",", beg + 1);

   }

It skips over the comma and takes everything that follows up to the next comma or EOL as the name. So the leading space is included and then the test that the first character of the name is an '@' fails and then that input isn't normalised. Of course, in 4.04/02 normalising wasn't optional and this logic did not exist.

How about, after the line:-

  end = (end == -1 ? input.Length() : end);

you add:-

   while (beg < (end-1) && isspace(input[beg])) beg++;

to skip leading white space? Strictly speaking that needs

  #include <cctype>

although when I tried it out it worked without it.

Cheers,

Nick. Received on Fri Mar 17 2006 - 07:59:10 MET

This archive was generated by hypermail 2.2.0 : Mon Jan 01 2007 - 16:31:57 MET