This macro provides an example of using a trained model with Keras and make inference using SOFIE with the RSofieReader class This macro uses as input a Keras model generated with the TMVA_Higgs_Classification.C tutorial You need to run that macro before to generate the trained Keras model
Execute in this order:
root TMVA_Higgs_Classification.C
std::vector<float>
input = {0.1,0.2,0.3,0.4,0.5,0.6,0.7};
std::cout <<
"Event prediction = " <<
output[0] << std::endl;
{"m_jj", "m_jjj", "m_lv", "m_jlv", "m_bb", "m_wbb", "m_wwbb"})
.Define("y","DNN_Values[0]")
.Histo1D({"h_sig", "", 100, 0, 1}, "y");
{"m_jj", "m_jjj", "m_lv", "m_jlv", "m_bb", "m_wbb", "m_wwbb"})
.Define("y","DNN_Values[0]")
.Histo1D({"h_bkg", "", 100, 0, 1}, "y");
h2->DrawClone();
}
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void input
R__EXTERN TStyle * gStyle
ROOT's RDataFrame offers a modern, high-level interface for analysis of data stored in TTree ,...
virtual void SetLineColor(Color_t lcolor)
Set the line color.
TMVA::RSofieReader class for reading external Machine Learning models in ONNX files,...
virtual TObject * DrawClone(Option_t *option="") const
Draw a clone of this object in the current selected pad with: gROOT->SetSelectedPad(c1).
void SetOptStat(Int_t stat=1)
The type of information printed in the histogram statistics box can be selected via the parameter mod...
input model type is Keras
Parsing SOFIE model HiggsModel of type keras
generating the code with batch size = 1 ...
executing python3 -c ......
"""
import ROOT
model = ROOT.TMVA.Experimental.SOFIE.PyKeras.Parse('HiggsModel.keras',1)
model.Generate(ROOT.TMVA.Experimental.SOFIE.Options.kDefault,1, 0, 1)
model.OutputGenerated('HiggsModel_fromRSofieR.hxx');
model.PrintRequiredInputTensors()
model.PrintIntermediateTensors()
model.PrintOutputTensors()
"""
Model Header file is generated!
compile generated code from file HiggsModel_fromRSofieR.hxx
- Author
- Lorenzo Moneta
Definition in file TMVA_SOFIE_RSofieReader.C.