# AddSpectator variable crashes with segmentation violation in multi class kPyKeras TMVA

**URL:** <https://root-forum.cern.ch/t/addspectator-variable-crashes-with-segmentation-violation-in-multi-class-kpykeras-tmva/42210>\
**Category:** TMVA\
**Tags:** python, tmva, root\
**Created:** [November 10, 2020, 5:58pm UTC](https://root-forum.cern.ch/t/addspectator-variable-crashes-with-segmentation-violation-in-multi-class-kpykeras-tmva/42210 "2020-11-10T17:58:27Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![okarache](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/okarache/32/21675_2.png) [@okarache](https://root-forum.cern.ch/u/okarache)\
**Post date:** [November 10, 2020, 5:58pm UTC](https://root-forum.cern.ch/t/addspectator-variable-crashes-with-segmentation-violation-in-multi-class-kpykeras-tmva/42210/1 "2020-11-10T17:58:27Z")

</div>

Dear ROOT experts,

could you help to figure out the cause of the segmentation violation crash when using pyKERAS multi classifier in TMVA, please?  
Below I will summarize the examples I was following and attach the code to reproduce the error.

This is an example I was using from ROOT tutorials: [https://root.cern/doc/v610/TMVAClassificationCategory\_8C.html](https://root.cern/doc/v610/TMVAClassificationCategory_8C.html). I also use .root file from this example to reproduce the issue.

First I tried to set up this example with spectator variable “eta” for only two classes: one signal tree and one background tree. So I used AddSignalTree and AddBackgroundTree. This works fine for kFisher (lines 75-78 in Spectator\_debug.py) and for kPyKeras (lines 111-120 in Spectator\_debug.py). For kPyKeras to work I have to source root 6.16, otherwise I run into error which was pointed out by other colleague here [Tensorflow crashes when factory has more than one pyKeras model booked](https://root-forum.cern.ch/t/tensorflow-crashes-when-factory-has-more-than-one-pykeras-model-booked/34509).

Now keeping the same setup and the same ROOT version 6.16 I’m seeing up multi class example. To use the same .root input file I just added signal1 and signal2 with different names, but it is the same root file. To set up multi class I can not use AddSignalTree and AddBackgroundTree, I need to add two different signals, so I used AddTree and gave different names to signal classes (lines 23-24 in Spectator\_debug\_multiClass.py). This training crashes with segmentation violation. Full error is in out\_segmentation.txt. To make sure that training would run fine without categories based on spectator variables I did run the test in lines 81-84 in Spectator\_debug\_multiClass.py an the one finished ok.

Please help me to figure out what causes segmentation violation when using categories based on spectator variables and kPyKeras.

Many thanks in advance,  
Olena

[Spectator\_debug.py](https://root-forum.cern.ch/uploads/short-url/y1NFPmCeTPh3YhDgKbucP3zpHyo.py) (5.2 KB) [Spectator\_debug\_multiClass.py](https://root-forum.cern.ch/uploads/short-url/2WKGWi74gmfHFw3a5EOjQdnui7u.py) (4.9 KB) [out\_segmentation.txt](https://root-forum.cern.ch/uploads/short-url/ayS1NtvBTVtGxFbWL1vsGJeNuhW.txt) (43.5 KB)

---

<div class="post-metadata">

**Author:** ![jblomer](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/j/439d5e/32.png) [@jblomer](https://root-forum.cern.ch/u/jblomer)\
**Post date:** [November 10, 2020, 9:19pm UTC](https://root-forum.cern.ch/t/addspectator-variable-crashes-with-segmentation-violation-in-multi-class-kpykeras-tmva/42210/2 "2020-11-10T21:19:12Z")

</div>

@moneta can you help?

---

<div class="post-metadata">

**Author:** ![moneta](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/moneta/32/19423_2.png) [@moneta](https://root-forum.cern.ch/u/moneta)\
**Post date:** [November 11, 2020, 10:28am UTC](https://root-forum.cern.ch/t/addspectator-variable-crashes-with-segmentation-violation-in-multi-class-kpykeras-tmva/42210/3 "2020-11-11T10:28:16Z")

</div>

Yes, I can reproduce the crash. I will investigate it

Lorenzo

---

<div class="post-metadata">

**Author:** ![okarache](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/okarache/32/21675_2.png) [@okarache](https://root-forum.cern.ch/u/okarache)\
**Post date:** [November 23, 2020, 2:36pm UTC](https://root-forum.cern.ch/t/addspectator-variable-crashes-with-segmentation-violation-in-multi-class-kpykeras-tmva/42210/4 "2020-11-23T14:36:36Z")

</div>

Thank you, Lorenzo!  
Please let me know it I can provide any other information, which can be helpful.

I’m looking forward to your reply,  
Olena

---

<div class="post-metadata">

**Author:** ![moneta](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/moneta/32/19423_2.png) [@moneta](https://root-forum.cern.ch/u/moneta)\
**Post date:** [November 23, 2020, 5:57pm UTC](https://root-forum.cern.ch/t/addspectator-variable-crashes-with-segmentation-violation-in-multi-class-kpykeras-tmva/42210/5 "2020-11-23T17:57:57Z")

</div>

Hi ,  
I have open an issue in github for this bug so you can monitor

> <https://github.com/root-project/root/issues/6872>
>
> See https://root-forum.cern.ch/t/addspectator-variable-crashes-with-segmentation-violation-in-multi-class-kpykeras-tmva/42210
> Script not using multi-class Spectator\_debug.py works fine while Spectator\_debug\_multiClass.py crashes in a segmentation violation.
> Furthermore time for evaluating network when using...

Thank you for reporting this  
Lorenzo
