Accessing array elements in multilayerpercerptron

I have a multilayerperceptron

TMultiLayerPerceptron *mlp = new TMultiLayerPerceptron(“my_jetpair_m[1],my_jetpair_m[2],my_jetpair_m[3]:8:4:my_Eventtype[0]”,tree_ImprovedData.tree(),“Entry
$%2”,"(Entry$+1)%2");

I want to use elements of an array as inputs eg my_jetpair_m[1], my_jetpair_m[2] etc, where the array is

Double_t my_jetpair_m[6]; //[my_jetpair_m_N]

and the branch address in my input tree is

improveddatatree->Branch(“my_jetpair_m”, &my_jetpair_m, “my_jetpair_m[my_jetpair_m_N]/D”);

When I try to do this I get the error below.

So I am wondering if anyone can tell me how I can use elements of an array as input to my multilayerperceptron?

Thank you!

Error in TLeafD::GetLen: Leaf counter is greater than maximum! leaf: ‘my_jetp air_m’ len: 55740480 max: 6
Error in TLeafD::GetLen: Leaf counter is greater than maximum! leaf: ‘my_jetp air_m’ len: 55740480 max: 6
Error in TLeafD::GetLen: Leaf counter is greater than maximum! leaf: ‘my_jetp air_m’ len: 55740480 max: 6
Error in TLeafD::GetLen: Leaf counter is greater than maximum! leaf: ‘my_jetp air_m’ len: 55740480 max: 6
Error in TLeafD::GetLen: Leaf counter is greater than maximum! leaf: ‘my_jetp air_m’ len: 55740480 max: 6
Error in TLeafD::GetLen: Leaf counter is greater than maximum! leaf: ‘my_jetp air_m’ len: 55740480 max: 6

*** Break *** segmentation violation
(no debugging symbols found)
Using host libthread_db library “/lib/tls/libthread_db.so.1”.
Attaching to program: /proc/32746/exe, process 32746
(no debugging symbols found)…done.
(no debugging symbols found)…done.
(no debugging symbols found)…done.
(no debugging symbols found)…done.
(no debugging symbols found)…done.
(no debugging symbols found)…done.
(no debugging symbols found)…done.
(no debugging symbols found)…done.
[Thread debugging using libthread_db enabled]
[New Thread -1208998208 (LWP 32746)]
(no debugging symbols found)…done.
(no debugging symbols found)…done.
(no debugging symbols found)…done.
(no debugging symbols found)…done.

0x004df7a2 in _dl_sysinfo_int80 () from /lib/ld-linux.so.2
#1 0x03489ff3 in __waitpid_nocancel () from /lib/tls/libc.so.6
#2 0x03434469 in do_system () from /lib/tls/libc.so.6
#3 0x0077e84d in system () from /lib/tls/libpthread.so.0
#4 0x00a82681 in TUnixSystem::Exec () from /usr/local/lib/root/libCore.so.5.14
#5 0x00a82abc in TUnixSystem::StackTrace ()
from /usr/local/lib/root/libCore.so.5.14
#6 0x00a80b22 in TUnixSystem::DispatchSignals ()
from /usr/local/lib/root/libCore.so.5.14
#7 0x00a7eb65 in SigHandler () from /usr/local/lib/root/libCore.so.5.14
#8 0x00a8501f in sighandler () from /usr/local/lib/root/libCore.so.5.14
#9
#10 0x00593c68 in TTreeFormula::LoadCurrentDim ()
from /usr/local/lib/root/libTreePlayer.so.5.14
#11 0x005960f1 in TTreeFormulaManager::GetNdata ()
from /usr/local/lib/root/libTreePlayer.so.5.14
#12 0x00591e1b in TTreeFormula::GetNdata ()
from /usr/local/lib/root/libTreePlayer.so.5.14
#13 0x007a4ec9 in TNeuron::UseBranch () from /usr/local/lib/root/libMLP.so.5.14
#14 0x0079c330 in TMultiLayerPerceptron::AttachData ()
from /usr/local/lib/root/libMLP.so.5.14
#15 0x00798ddf in TMultiLayerPerceptron::TMultiLayerPerceptron ()
from /usr/local/lib/root/libMLP.so.5.14
#16 0x0804a8f4 in main ()

Hi,

Most likely you did not initalize the variable/address corresponding to my_jetpair_m_N

Cheers,
Philippe.

In fact I have - I can access the information outside of the constructor, but inside the multilayerperceptron I have this problem.


I think the problem is there. The correct synthax is: 
[code]improveddatatree->Branch("my_jetpair_m",my_jetpair_m, "my_jetpair_m[my_jetpair_m_N]/D");[/code], without the ampersand (The name of an array is already the address of the first item).

TMultiLayerPerceptron internally uses TFormula to decode the input, there is nothing special there. In your case, the following would probably fail too:
[code]improveddatatree->Scan("my_jetpair_m[1]:my_jetpair_m[2]:my_jetpair_m[3]")[/code]

I think the problem is there. The correct synthax is:

improveddatatree->Branch("my_jetpair_m",my_jetpair_m, "my_jetpair_m[my_jetpair_m_N]/D");, without the ampersand (The name of an array is already the address of the first item).

TMultiLayerPerceptron internally uses TFormula to decode the input, there is nothing special there. In your case, the following would probably fail too:

Thank you for the response. I still have the same problem wthout the &.

tree->Scan(“my_jetpair_m[1]:my_jetpair_m[2]:my_jetpair_m[3]”)

does work. I am wondering if it is in fact possible to access array elements using multilayerperceptron?

Does the tree.Scan() work ?

TMultiLayerPerceptron was tested with arrays without problem. Since there is no special handling for that case (everything is handled by the TFormula) I don’t see why that would have changed.

Since you have the same behavior with and without the ampersand, I suspect that the problem is at the level of memory allocation of your tree, not really with the NN.