Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TMVA_SOFIE_Models.py File Reference

Detailed Description

View in nbviewer Open in SWAN
Example of inference with SOFIE using a set of models trained with Keras.

This tutorial shows how to store several models in a single header file and the weights in a ROOT binary file. The models are then evaluated using the RDataFrame First, generate the input model by running TMVA_Higgs_Classification.C.

This tutorial parses the input model and runs the inference using ROOT's JITing capability.

import contextlib
import os
import warnings
import numpy as np
import ROOT
from sklearn.model_selection import train_test_split
from tensorflow.keras.layers import Dense, Input
from tensorflow.keras.models import Sequential
@contextlib.contextmanager
def expect_warning(category, message):
"""Silence a known third-party warning. Raise if it stops firing.
Notifies us to drop the workaround once the upstream library is fixed.
"""
with warnings.catch_warnings(record=True) as caught:
yield
seen = False
for w in caught:
if issubclass(w.category, category) and message in str(w.message):
seen = True
else:
if not seen:
raise RuntimeError(
f"Expected {category.__name__} containing {message!r} was not "
"emitted. This tutorial's workaround can probably be removed."
)
## generate and train Keras models with different architectures
def CreateModel(nlayers=4, nunits=64):
model = Sequential()
model.add(Input(shape=(7,)))
model.add(Dense(nunits, activation="relu"))
for i in range(1, nlayers):
model.add(Dense(nunits, activation="relu"))
model.add(Dense(1, activation="sigmoid"))
model.compile(loss="binary_crossentropy", optimizer=Adam(learning_rate=0.001), weighted_metrics=["accuracy"])
return model
# get the input data
inputFile = str(ROOT.gROOT.GetTutorialDir()) + "/machine_learning/data/Higgs_data.root"
df1 = ROOT.RDataFrame("sig_tree", inputFile)
sigData = df1.AsNumpy(columns=["m_jj", "m_jjj", "m_lv", "m_jlv", "m_bb", "m_wbb", "m_wwbb"])
# print(sigData)
# stack all the 7 numpy array in a single array (nevents x nvars)
data_sig_size = xsig.shape[0]
print("size of data", data_sig_size)
# make SOFIE inference on background data
df2 = ROOT.RDataFrame("bkg_tree", inputFile)
bkgData = df2.AsNumpy(columns=["m_jj", "m_jjj", "m_lv", "m_jlv", "m_bb", "m_wbb", "m_wwbb"])
data_bkg_size = xbkg.shape[0]
ysig = np.ones(data_sig_size)
ybkg = np.zeros(data_bkg_size)
inputs_data = np.concatenate((xsig, xbkg), axis=0)
inputs_targets = np.concatenate((ysig, ybkg), axis=0)
# split data in training and test data
x_train, x_test, y_train, y_test = train_test_split(inputs_data, inputs_targets, test_size=0.50, random_state=1234)
return x_train, y_train, x_test, y_test
def TrainModel(model, x, y, name):
model.fit(x, y, epochs=5, batch_size=50)
modelFile = name + ".keras"
# Keras' internal ``np.array(x)`` (TensorFlow backend) does not yet
# implement the NumPy 2.0 ``__array__(copy=...)`` signature, so saving
# emits a DeprecationWarning that we cannot fix from user code.
if tuple(int(p) for p in np.__version__.split(".")[:2]) >= (2, 0):
ctx = expect_warning(DeprecationWarning, "__array__ implementation doesn't accept a copy keyword")
else:
with ctx:
model.save(modelFile)
return modelFile
### run the models
x_train, y_train, x_test, y_test = PrepareData()
## create models and train them
model1 = TrainModel(CreateModel(4, 64), x_train, y_train, "Higgs_Model_4L_50")
model2 = TrainModel(CreateModel(4, 64), x_train, y_train, "Higgs_Model_4L_200")
model3 = TrainModel(CreateModel(4, 64), x_train, y_train, "Higgs_Model_2L_500")
# evaluate with SOFIE the 3 trained models
def GenerateModelCode(modelFile, generatedHeaderFile):
print("Generating inference code for the Keras model from ", modelFile, "in the header ", generatedHeaderFile)
# Generating inference code using a ROOT binary file
# add option to append to the same file the generated headers (pass True for append flag)
model.OutputGenerated(generatedHeaderFile, True)
# model.PrintGenerated()
return generatedHeaderFile
generatedHeaderFile = "Higgs_Model.hxx"
# need to remove existing header file since we are appending on same one
if os.path.exists(generatedHeaderFile):
print("removing existing file", generatedHeaderFile)
os.remove(generatedHeaderFile)
weightFile = "Higgs_Model.root"
if os.path.exists(weightFile):
print("removing existing file", weightFile)
os.remove(weightFile)
GenerateModelCode(model1, generatedHeaderFile)
GenerateModelCode(model2, generatedHeaderFile)
GenerateModelCode(model3, generatedHeaderFile)
# compile the generated code
ROOT.gInterpreter.Declare('#include "' + generatedHeaderFile + '"')
# run the inference on the test data
session1 = ROOT.TMVA_SOFIE_Higgs_Model_4L_50.Session("Higgs_Model.root")
session2 = ROOT.TMVA_SOFIE_Higgs_Model_4L_200.Session("Higgs_Model.root")
session3 = ROOT.TMVA_SOFIE_Higgs_Model_2L_500.Session("Higgs_Model.root")
hs1 = ROOT.TH1D("hs1", "Signal result 4L 50", 100, 0, 1)
hs2 = ROOT.TH1D("hs2", "Signal result 4L 200", 100, 0, 1)
hs3 = ROOT.TH1D("hs3", "Signal result 2L 500", 100, 0, 1)
hb1 = ROOT.TH1D("hb1", "Background result 4L 50", 100, 0, 1)
hb2 = ROOT.TH1D("hb2", "Background result 4L 200", 100, 0, 1)
hb3 = ROOT.TH1D("hb3", "Background result 2L 500", 100, 0, 1)
def EvalModel(session, x):
result = session.infer(x)
return result[0]
for i in range(0, x_test.shape[0]):
result1 = EvalModel(session1, x_test[i, :])
result2 = EvalModel(session2, x_test[i, :])
result3 = EvalModel(session3, x_test[i, :])
if y_test[i] == 1:
hs1.Fill(result1)
hs2.Fill(result2)
hs3.Fill(result3)
else:
hb1.Fill(result1)
hb2.Fill(result2)
hb3.Fill(result3)
def PlotHistos(hs, hb):
hb.SetLineColor("kBlue")
hb.Draw("same")
c1.Divide(1, 3)
PlotHistos(hs1, hb1)
PlotHistos(hs2, hb2)
PlotHistos(hs3, hb3)
## draw also ROC curves
def GetContent(h):
x = ROOT.std.vector["float"](n)
w = ROOT.std.vector["float"](n)
for i in range(0, n):
x[i] = h.GetBinCenter(i + 1)
w[i] = h.GetBinContent(i + 1)
return x, w
def MakeROCCurve(hs, hb):
xs, ws = GetContent(hs)
xb, wb = GetContent(hb)
roc = ROOT.TMVA.ROCCurve(xs, xb, ws, wb)
print("ROC integral for ", hs.GetName(), roc.GetROCIntegral())
curve = roc.GetROCCurve()
return roc, curve
r1, curve1 = MakeROCCurve(hs1, hb1)
r2, curve2 = MakeROCCurve(hs2, hb2)
r3, curve3 = MakeROCCurve(hs3, hb3)
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
ROOT's RDataFrame offers a modern, high-level interface for analysis of data stored in TTree ,...
size of data 10000
Model: "sequential"
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┓
┃ Layer (type) ┃ Output Shape ┃ Param # ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━┩
│ dense (Dense) │ (None, 64) │ 512 │
├─────────────────────────────────┼────────────────────────┼───────────────┤
│ dense_1 (Dense) │ (None, 64) │ 4,160 │
├─────────────────────────────────┼────────────────────────┼───────────────┤
│ dense_2 (Dense) │ (None, 64) │ 4,160 │
├─────────────────────────────────┼────────────────────────┼───────────────┤
│ dense_3 (Dense) │ (None, 64) │ 4,160 │
├─────────────────────────────────┼────────────────────────┼───────────────┤
│ dense_4 (Dense) │ (None, 1) │ 65 │
└─────────────────────────────────┴────────────────────────┴───────────────┘
Total params: 13,057 (51.00 KB)
Trainable params: 13,057 (51.00 KB)
Non-trainable params: 0 (0.00 B)
Epoch 1/5
␛[1m 1/200␛[0m ␛[37m━━━━━━━━━━━━━━━━━━━━␛[0m ␛[1m2:12␛[0m 668ms/step - accuracy: 0.5400 - loss: 0.6865␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈
␛[1m 59/200␛[0m ␛[32m━━━━━␛[0m␛[37m━━━━━━━━━━━━━━━␛[0m ␛[1m0s␛[0m 873us/step - accuracy: 0.5542 - loss: 0.6808 ␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈
␛[1m119/200␛[0m ␛[32m━━━━━━━━━━━␛[0m␛[37m━━━━━━━━━␛[0m ␛[1m0s␛[0m 855us/step - accuracy: 0.5780 - loss: 0.6693␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈
␛[1m182/200␛[0m ␛[32m━━━━━━━━━━━━━━━━━━␛[0m␛[37m━━␛[0m ␛[1m0s␛[0m 834us/step - accuracy: 0.5860 - loss: 0.6644␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈
␛[1m200/200␛[0m ␛[32m━━━━━━━━━━━━━━━━━━━━␛[0m␛[37m␛[0m ␛[1m1s␛[0m 884us/step - accuracy: 0.5863 - loss: 0.6638
Epoch 2/5
␛[1m 1/200␛[0m ␛[37m━━━━━━━━━━━━━━━━━━━━␛[0m ␛[1m2s␛[0m 12ms/step - accuracy: 0.6600 - loss: 0.6982␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈
␛[1m 61/200␛[0m ␛[32m━━━━━━␛[0m␛[37m━━━━━━━━━━━━━━␛[0m ␛[1m0s␛[0m 841us/step - accuracy: 0.6072 - loss: 0.6506␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈
␛[1m124/200␛[0m ␛[32m━━━━━━━━━━━━␛[0m␛[37m━━━━━━━━␛[0m ␛[1m0s␛[0m 822us/step - accuracy: 0.6229 - loss: 0.6453␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈
␛[1m186/200␛[0m ␛[32m━━━━━━━━━━━━━━━━━━␛[0m␛[37m━━␛[0m ␛[1m0s␛[0m 821us/step - accuracy: 0.6260 - loss: 0.6429␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈
␛[1m200/200␛[0m ␛[32m━━━━━━━━━━━━━━━━━━━━␛[0m␛[37m␛[0m ␛[1m0s␛[0m 871us/step - accuracy: 0.6262 - loss: 0.6438
Epoch 3/5
␛[1m 1/200␛[0m ␛[37m━━━━━━━━━━━━━━━━━━━━␛[0m ␛[1m2s␛[0m 12ms/step - accuracy: 0.5400 - loss: 0.6926␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈
␛[1m 62/200␛[0m ␛[32m━━━━━━␛[0m␛[37m━━━━━━━━━━━━━━␛[0m ␛[1m0s␛[0m 832us/step - accuracy: 0.6481 - loss: 0.6346␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈
␛[1m123/200␛[0m ␛[32m━━━━━━━━━━━━␛[0m␛[37m━━━━━━━━␛[0m ␛[1m0s␛[0m 830us/step - accuracy: 0.6431 - loss: 0.6350␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈
␛[1m185/200␛[0m ␛[32m━━━━━━━━━━━━━━━━━━␛[0m␛[37m━━␛[0m ␛[1m0s␛[0m 824us/step - accuracy: 0.6481 - loss: 0.6317␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈
␛[1m200/200␛[0m ␛[32m━━━━━━━━━━━━━━━━━━━━␛[0m␛[37m␛[0m ␛[1m0s␛[0m 874us/step - accuracy: 0.6471 - loss: 0.6320
Epoch 4/5
␛[1m 1/200␛[0m ␛[37m━━━━━━━━━━━━━━━━━━━━␛[0m ␛[1m2s␛[0m 12ms/step - accuracy: 0.6000 - loss: 0.7051␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈
␛[1m 62/200␛[0m ␛[32m━━━━━━␛[0m␛[37m━━━━━━━━━━━━━━␛[0m ␛[1m0s␛[0m 833us/step - accuracy: 0.6471 - loss: 0.6346␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈
␛[1m123/200␛[0m ␛[32m━━━━━━━━━━━━␛[0m␛[37m━━━━━━━━␛[0m ␛[1m0s␛[0m 831us/step - accuracy: 0.6501 - loss: 0.6281␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈
␛[1m187/200␛[0m ␛[32m━━━━━━━━━━━━━━━━━━␛[0m␛[37m━━␛[0m ␛[1m0s␛[0m 818us/step - accuracy: 0.6563 - loss: 0.6212␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈
␛[1m200/200␛[0m ␛[32m━━━━━━━━━━━━━━━━━━━━␛[0m␛[37m␛[0m ␛[1m0s␛[0m 865us/step - accuracy: 0.6573 - loss: 0.6200
Epoch 5/5
␛[1m 1/200␛[0m ␛[37m━━━━━━━━━━━━━━━━━━━━␛[0m ␛[1m2s␛[0m 12ms/step - accuracy: 0.6400 - loss: 0.6062␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈
␛[1m 60/200␛[0m ␛[32m━━━━━━␛[0m␛[37m━━━━━━━━━━━━━━␛[0m ␛[1m0s␛[0m 857us/step - accuracy: 0.6597 - loss: 0.6107␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈
␛[1m119/200␛[0m ␛[32m━━━━━━━━━━━␛[0m␛[37m━━━━━━━━━␛[0m ␛[1m0s␛[0m 853us/step - accuracy: 0.6575 - loss: 0.6143␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈
␛[1m179/200␛[0m ␛[32m━━━━━━━━━━━━━━━━━␛[0m␛[37m━━━␛[0m ␛[1m0s␛[0m 849us/step - accuracy: 0.6590 - loss: 0.6140␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈
␛[1m200/200␛[0m ␛[32m━━━━━━━━━━━━━━━━━━━━␛[0m␛[37m␛[0m ␛[1m0s␛[0m 899us/step - accuracy: 0.6599 - loss: 0.6138
Model: "sequential_1"
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┓
┃ Layer (type) ┃ Output Shape ┃ Param # ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━┩
│ dense_5 (Dense) │ (None, 64) │ 512 │
├─────────────────────────────────┼────────────────────────┼───────────────┤
│ dense_6 (Dense) │ (None, 64) │ 4,160 │
├─────────────────────────────────┼────────────────────────┼───────────────┤
│ dense_7 (Dense) │ (None, 64) │ 4,160 │
├─────────────────────────────────┼────────────────────────┼───────────────┤
│ dense_8 (Dense) │ (None, 64) │ 4,160 │
├─────────────────────────────────┼────────────────────────┼───────────────┤
│ dense_9 (Dense) │ (None, 1) │ 65 │
└─────────────────────────────────┴────────────────────────┴───────────────┘
Total params: 13,057 (51.00 KB)
Trainable params: 13,057 (51.00 KB)
Non-trainable params: 0 (0.00 B)
Epoch 1/5
␛[1m 1/200␛[0m ␛[37m━━━━━━━━━━━━━━━━━━━━␛[0m ␛[1m2:10␛[0m 655ms/step - accuracy: 0.5600 - loss: 0.6912␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈
␛[1m 62/200␛[0m ␛[32m━━━━━━␛[0m␛[37m━━━━━━━━━━━━━━␛[0m ␛[1m0s␛[0m 832us/step - accuracy: 0.5448 - loss: 0.6823 ␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈
␛[1m126/200␛[0m ␛[32m━━━━━━━━━━━━␛[0m␛[37m━━━━━━━━␛[0m ␛[1m0s␛[0m 811us/step - accuracy: 0.5614 - loss: 0.6747␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈
␛[1m189/200␛[0m ␛[32m━━━━━━━━━━━━━━━━━━␛[0m␛[37m━━␛[0m ␛[1m0s␛[0m 809us/step - accuracy: 0.5782 - loss: 0.6698␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈
␛[1m200/200␛[0m ␛[32m━━━━━━━━━━━━━━━━━━━━␛[0m␛[37m␛[0m ␛[1m1s␛[0m 857us/step - accuracy: 0.5802 - loss: 0.6688
Epoch 2/5
␛[1m 1/200␛[0m ␛[37m━━━━━━━━━━━━━━━━━━━━␛[0m ␛[1m2s␛[0m 12ms/step - accuracy: 0.6000 - loss: 0.6811␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈
␛[1m 62/200␛[0m ␛[32m━━━━━━␛[0m␛[37m━━━━━━━━━━━━━━␛[0m ␛[1m0s␛[0m 821us/step - accuracy: 0.6168 - loss: 0.6495␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈
␛[1m128/200␛[0m ␛[32m━━━━━━━━━━━━␛[0m␛[37m━━━━━━━━␛[0m ␛[1m0s␛[0m 793us/step - accuracy: 0.6244 - loss: 0.6475␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈
␛[1m200/200␛[0m ␛[32m━━━━━━━━━━━━━━━━━━━━␛[0m␛[37m␛[0m ␛[1m0s␛[0m 760us/step - accuracy: 0.6248 - loss: 0.6455␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈
␛[1m200/200␛[0m ␛[32m━━━━━━━━━━━━━━━━━━━━␛[0m␛[37m␛[0m ␛[1m0s␛[0m 809us/step - accuracy: 0.6248 - loss: 0.6455
Epoch 3/5
␛[1m 1/200␛[0m ␛[37m━━━━━━━━━━━━━━━━━━━━␛[0m ␛[1m2s␛[0m 11ms/step - accuracy: 0.6800 - loss: 0.6050␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈
␛[1m 70/200␛[0m ␛[32m━━━━━━━␛[0m␛[37m━━━━━━━━━━━━━␛[0m ␛[1m0s␛[0m 727us/step - accuracy: 0.6351 - loss: 0.6344␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈
␛[1m139/200␛[0m ␛[32m━━━━━━━━━━━━━␛[0m␛[37m━━━━━━━␛[0m ␛[1m0s␛[0m 726us/step - accuracy: 0.6429 - loss: 0.6313␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈
␛[1m200/200␛[0m ␛[32m━━━━━━━━━━━━━━━━━━━━␛[0m␛[37m␛[0m ␛[1m0s␛[0m 780us/step - accuracy: 0.6451 - loss: 0.6296
Epoch 4/5
␛[1m 1/200␛[0m ␛[37m━━━━━━━━━━━━━━━━━━━━␛[0m ␛[1m2s␛[0m 11ms/step - accuracy: 0.6400 - loss: 0.6053␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈
␛[1m 68/200␛[0m ␛[32m━━━━━━␛[0m␛[37m━━━━━━━━━━━━━━␛[0m ␛[1m0s␛[0m 755us/step - accuracy: 0.6500 - loss: 0.6179␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈
␛[1m136/200␛[0m ␛[32m━━━━━━━━━━━━━␛[0m␛[37m━━━━━━━␛[0m ␛[1m0s␛[0m 749us/step - accuracy: 0.6475 - loss: 0.6222␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈
␛[1m200/200␛[0m ␛[32m━━━━━━━━━━━━━━━━━━━━␛[0m␛[37m␛[0m ␛[1m0s␛[0m 777us/step - accuracy: 0.6477 - loss: 0.6231
Epoch 5/5
␛[1m 1/200␛[0m ␛[37m━━━━━━━━━━━━━━━━━━━━␛[0m ␛[1m2s␛[0m 11ms/step - accuracy: 0.8400 - loss: 0.5542␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈
␛[1m 73/200␛[0m ␛[32m━━━━━━━␛[0m␛[37m━━━━━━━━━━━━━␛[0m ␛[1m0s␛[0m 700us/step - accuracy: 0.6510 - loss: 0.6193␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈
␛[1m145/200␛[0m ␛[32m━━━━━━━━━━━━━━␛[0m␛[37m━━━━━━␛[0m ␛[1m0s␛[0m 699us/step - accuracy: 0.6503 - loss: 0.6222␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈
␛[1m200/200␛[0m ␛[32m━━━━━━━━━━━━━━━━━━━━␛[0m␛[37m␛[0m ␛[1m0s␛[0m 770us/step - accuracy: 0.6539 - loss: 0.6191
Model: "sequential_2"
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┓
┃ Layer (type) ┃ Output Shape ┃ Param # ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━┩
│ dense_10 (Dense) │ (None, 64) │ 512 │
├─────────────────────────────────┼────────────────────────┼───────────────┤
│ dense_11 (Dense) │ (None, 64) │ 4,160 │
├─────────────────────────────────┼────────────────────────┼───────────────┤
│ dense_12 (Dense) │ (None, 64) │ 4,160 │
├─────────────────────────────────┼────────────────────────┼───────────────┤
│ dense_13 (Dense) │ (None, 64) │ 4,160 │
├─────────────────────────────────┼────────────────────────┼───────────────┤
│ dense_14 (Dense) │ (None, 1) │ 65 │
└─────────────────────────────────┴────────────────────────┴───────────────┘
Total params: 13,057 (51.00 KB)
Trainable params: 13,057 (51.00 KB)
Non-trainable params: 0 (0.00 B)
Epoch 1/5
␛[1m 1/200␛[0m ␛[37m━━━━━━━━━━━━━━━━━━━━␛[0m ␛[1m2:01␛[0m 610ms/step - accuracy: 0.6800 - loss: 0.6894␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈
␛[1m 59/200␛[0m ␛[32m━━━━━␛[0m␛[37m━━━━━━━━━━━━━━━␛[0m ␛[1m0s␛[0m 874us/step - accuracy: 0.5420 - loss: 0.6872 ␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈
␛[1m123/200␛[0m ␛[32m━━━━━━━━━━━━␛[0m␛[37m━━━━━━━━␛[0m ␛[1m0s␛[0m 831us/step - accuracy: 0.5598 - loss: 0.6804␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈
␛[1m195/200␛[0m ␛[32m━━━━━━━━━━━━━━━━━━━␛[0m␛[37m━␛[0m ␛[1m0s␛[0m 782us/step - accuracy: 0.5758 - loss: 0.6710␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈
␛[1m200/200␛[0m ␛[32m━━━━━━━━━━━━━━━━━━━━␛[0m␛[37m␛[0m ␛[1m1s␛[0m 830us/step - accuracy: 0.5776 - loss: 0.6699
Epoch 2/5
␛[1m 1/200␛[0m ␛[37m━━━━━━━━━━━━━━━━━━━━␛[0m ␛[1m2s␛[0m 11ms/step - accuracy: 0.5600 - loss: 0.6878␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈
␛[1m 67/200␛[0m ␛[32m━━━━━━␛[0m␛[37m━━━━━━━━━━━━━━␛[0m ␛[1m0s␛[0m 758us/step - accuracy: 0.6194 - loss: 0.6488␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈
␛[1m133/200␛[0m ␛[32m━━━━━━━━━━━━━␛[0m␛[37m━━━━━━━␛[0m ␛[1m0s␛[0m 761us/step - accuracy: 0.6226 - loss: 0.6462␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈
␛[1m199/200␛[0m ␛[32m━━━━━━━━━━━━━━━━━━━␛[0m␛[37m━␛[0m ␛[1m0s␛[0m 760us/step - accuracy: 0.6288 - loss: 0.6444␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈
␛[1m200/200␛[0m ␛[32m━━━━━━━━━━━━━━━━━━━━␛[0m␛[37m␛[0m ␛[1m0s␛[0m 809us/step - accuracy: 0.6289 - loss: 0.6444
Epoch 3/5
␛[1m 1/200␛[0m ␛[37m━━━━━━━━━━━━━━━━━━━━␛[0m ␛[1m2s␛[0m 11ms/step - accuracy: 0.5400 - loss: 0.6997␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈
␛[1m 68/200␛[0m ␛[32m━━━━━━␛[0m␛[37m━━━━━━━━━━━━━━␛[0m ␛[1m0s␛[0m 754us/step - accuracy: 0.6468 - loss: 0.6312␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈
␛[1m135/200␛[0m ␛[32m━━━━━━━━━━━━━␛[0m␛[37m━━━━━━━␛[0m ␛[1m0s␛[0m 754us/step - accuracy: 0.6450 - loss: 0.6321␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈
␛[1m200/200␛[0m ␛[32m━━━━━━━━━━━━━━━━━━━━␛[0m␛[37m␛[0m ␛[1m0s␛[0m 761us/step - accuracy: 0.6483 - loss: 0.6291␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈
␛[1m200/200␛[0m ␛[32m━━━━━━━━━━━━━━━━━━━━␛[0m␛[37m␛[0m ␛[1m0s␛[0m 810us/step - accuracy: 0.6483 - loss: 0.6291
Epoch 4/5
␛[1m 1/200␛[0m ␛[37m━━━━━━━━━━━━━━━━━━━━␛[0m ␛[1m2s␛[0m 11ms/step - accuracy: 0.6800 - loss: 0.5634␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈
␛[1m 71/200␛[0m ␛[32m━━━━━━━␛[0m␛[37m━━━━━━━━━━━━━␛[0m ␛[1m0s␛[0m 722us/step - accuracy: 0.6479 - loss: 0.6259␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈
␛[1m140/200␛[0m ␛[32m━━━━━━━━━━━━━━␛[0m␛[37m━━━━━━␛[0m ␛[1m0s␛[0m 726us/step - accuracy: 0.6521 - loss: 0.6238␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈
␛[1m200/200␛[0m ␛[32m━━━━━━━━━━━━━━━━━━━━␛[0m␛[37m␛[0m ␛[1m0s␛[0m 772us/step - accuracy: 0.6501 - loss: 0.6247
Epoch 5/5
␛[1m 1/200␛[0m ␛[37m━━━━━━━━━━━━━━━━━━━━␛[0m ␛[1m2s␛[0m 11ms/step - accuracy: 0.6400 - loss: 0.6348␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈
␛[1m 56/200␛[0m ␛[32m━━━━━␛[0m␛[37m━━━━━━━━━━━━━━━␛[0m ␛[1m0s␛[0m 915us/step - accuracy: 0.6639 - loss: 0.6093␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈
␛[1m126/200␛[0m ␛[32m━━━━━━━━━━━━␛[0m␛[37m━━━━━━━━␛[0m ␛[1m0s␛[0m 803us/step - accuracy: 0.6576 - loss: 0.6138␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈
␛[1m197/200␛[0m ␛[32m━━━━━━━━━━━━━━━━━━━␛[0m␛[37m━␛[0m ␛[1m0s␛[0m 770us/step - accuracy: 0.6569 - loss: 0.6156␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈␈
␛[1m200/200␛[0m ␛[32m━━━━━━━━━━━━━━━━━━━━␛[0m␛[37m␛[0m ␛[1m0s␛[0m 820us/step - accuracy: 0.6579 - loss: 0.6154
PyKeras: parsing model Higgs_Model_4L_50.keras
Generating inference code for the Keras model from Higgs_Model_4L_50.keras in the header Higgs_Model.hxx
PyKeras: parsing model Higgs_Model_4L_200.keras
Generating inference code for the Keras model from Higgs_Model_4L_200.keras in the header Higgs_Model.hxx
PyKeras: parsing model Higgs_Model_2L_500.keras
Generating inference code for the Keras model from Higgs_Model_2L_500.keras in the header Higgs_Model.hxx
ROC integral for hs1 0.7271026019375968
ROC integral for hs2 0.7273281090094985
ROC integral for hs3 0.7282112167037558
Author
Lorenzo Moneta

Definition in file TMVA_SOFIE_Models.py.