This macro provides an example of using a trained model with Keras and make inference using SOFIE directly from Numpy This macro uses as input a Keras model generated with the TMVA_Higgs_Classification.C tutorial You need to run that macro before this one.
In this case we are parsing the input file and then run the inference in the same macro making use of the ROOT JITing capability
import ROOT
import numpy as np
modelFile = "Higgs_trained_model.h5"
ROOT.Info(
"TMVA_SOFIE_RDataFrame",
"You need to run TMVA_Higgs_Classification.C to generate the Keras trained model")
print("Generating inference code for the Keras model from ",modelFile,"in the header ", generatedHeaderFile)
print("compiling SOFIE model ", modelName)
print("Generating inference code for the Keras model from ",modelFile,"in the header ", generatedHeaderFile)
inputFileName = "Higgs_data.root"
sigData =
df1.AsNumpy(columns=[
'm_jj',
'm_jjj',
'm_lv',
'm_jlv',
'm_bb',
'm_wbb',
'm_wwbb'])
print("size of data", dataset_size)
for i
in range(0,dataset_size):
bkgData =
df2.AsNumpy(columns=[
'm_jj',
'm_jjj',
'm_lv',
'm_jlv',
'm_bb',
'm_wbb',
'm_wwbb'])
hb =
ROOT.TH1D(
"hb",
"Background result",100,0,1)
for i
in range(0,dataset_size):
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 ,...
- Author
- Lorenzo Moneta
Definition in file TMVA_SOFIE_Inference.py.